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 26, 2024
1 parent 3025d14 commit 515d1b9
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 2 deletions.
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
4 changes: 3 additions & 1 deletion pkg/util/entrypoint/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const (
KubeVipConfigPB = "config-for-kube-vip.yml"
ConfigInsecureRegistryPB = "config-insecure-registry.yml"
NfConntrackPB = "enable-nf-conntrack.yml"
MountXFSPquotaPB = "mount-xfs-pquota.yml"
)

//go:embed entrypoint.sh.template
Expand All @@ -62,7 +63,8 @@ func NewActions() *Actions {
actions.Playbooks.List = []string{
ResetPB, ScalePB, ClusterPB, RemoveNodePB, UpgradeClusterPB,
PingPB, RepoPB, FirewallPB, KubeconfigPB, ClusterInfoPB, UpdateHostsPB,
RemovePkgsPB, PreCheckPB, RenewCertsPB, KubeVipConfigPB, ConfigInsecureRegistryPB, NfConntrackPB,
RemovePkgsPB, PreCheckPB, RenewCertsPB,
KubeVipConfigPB, ConfigInsecureRegistryPB, NfConntrackPB, MountXFSPquotaPB,
}
actions.Playbooks.Dict = map[string]void{}
for _, pbItem := range actions.Playbooks.List {
Expand Down
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 515d1b9

Please sign in to comment.