Skip to content

Commit

Permalink
playbook: mount xfs device with pquota option
Browse files Browse the repository at this point in the history
Signed-off-by: bo.jiang <[email protected]>
  • Loading branch information
ErikJiang committed Mar 25, 2024
1 parent 3025d14 commit 7f7e19c
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .ansible-lint
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ warn_list:
- ignore-errors # Use failed_when and specify error conditions instead of using ignore_errors.
exclude_paths:
- playbooks/disable-firewalld.yml
- playbooks/config-for-kube-vip.yml
- playbooks/config-for-kube-vip.yml
- playbooks/mount-xfs-pquota.yml
72 changes: 72 additions & 0 deletions playbooks/mount-xfs-pquota.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright 2023 Authors of kubean-io
# SPDX-License-Identifier: Apache-2.0

---

# https://docs.docker.com/reference/cli/dockerd/#overlay2-options
- name: Mount up device with xfs pquota
hosts: k8s_cluster,etcd
gather_facts: true
become: true
any_errors_fatal: "{{ any_errors_fatal | default(true) }}"
vars:
docker_mount_device: ""
docker_storage_options: ""
docker_daemon_graph: /var/lib/docker
tasks:
- name: Stop if `docker_mount_device` is not defined or `docker_mount_device` is empty
assert:
that:
- docker_mount_device is defined
- docker_mount_device != ""
msg: >
When configuring overlay2.size in `docker_storage_options`, `docker_mount_device` needs to be set.
when: "'overlay2.size' in docker_storage_options"

- name: Get device mount info
shell: lsblk -n -o MOUNTPOINT {{ docker_mount_device }}
register: mount_info
changed_when: false
failed_when: false
when: "'overlay2.size' in docker_storage_options"

- name: debug
debug:
msg: "mount_info: {{ mount_info }}"
when:
- "'overlay2.size' in docker_storage_options"
- debug | default(false)

- name: Stop if the device outputs an error
assert:
that:
- mount_info.stderr_lines | length == 0
msg: >
device error: {{ mount_info.stderr_lines }}.
when: "'overlay2.size' in docker_storage_options"

- name: Stop if the device is mounted to a non {{ docker_daemon_graph }} directory.
fail:
msg: >
The device {{ docker_mount_device }} has been mounted to the {{ mount_info.stdout_lines[0] }} directory.
when:
- "'overlay2.size' in docker_storage_options"
- mount_info.stdout_lines | length > 0
- mount_info.stdout_lines[0] != docker_daemon_graph

- name: "Create a xfs filesystem on {{ docker_mount_device }}"
community.general.filesystem:
fstype: xfs
dev: "{{ docker_mount_device }}"
when:
- "'overlay2.size' in docker_storage_options"

- name: Mount up xfs device with pquota option
mount:
path: "{{ docker_daemon_graph }}"
src: "{{ docker_mount_device }}"
fstype: xfs
opts: pquota
state: mounted
when:
- "'overlay2.size' in docker_storage_options"

0 comments on commit 7f7e19c

Please sign in to comment.