fix ansible-lint errors
This commit is contained in:
@@ -13,4 +13,4 @@
|
|||||||
bhard: "100M"
|
bhard: "100M"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "0700"
|
mode: "0700"
|
||||||
|
|||||||
@@ -5,33 +5,33 @@
|
|||||||
- name: Get /root/image.img stats
|
- name: Get /root/image.img stats
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: /root/image.img
|
path: /root/image.img
|
||||||
register: img_stat
|
register: xfs_project_quotas_img_stat
|
||||||
|
|
||||||
- name: Create image file
|
- name: Create image file
|
||||||
when: not img_stat.stat.exists
|
when: not xfs_project_quotas_img_stat.stat.exists
|
||||||
ansible.builtin.command: dd if=/dev/zero of=/root/image.img bs=1M count=400
|
ansible.builtin.command: dd if=/dev/zero of=/root/image.img bs=1M count=400
|
||||||
register: dd_result
|
register: xfs_project_quotas_dd_result
|
||||||
changed_when: dd_result.rc == 0
|
changed_when: xfs_project_quotas_dd_result.rc == 0
|
||||||
|
|
||||||
- name: Get linked loop devices
|
- name: Get linked loop devices
|
||||||
ansible.builtin.command: losetup -a
|
ansible.builtin.command: losetup -a
|
||||||
changed_when: false
|
changed_when: false
|
||||||
register: loop_devs
|
register: xfs_project_quotas_loop_devs
|
||||||
|
|
||||||
- name: Link image to loop device
|
- name: Link image to loop device
|
||||||
when: "'/root/image.img' not in loop_devs.stdout"
|
when: "'/root/image.img' not in xfs_project_quotas_loop_devs.stdout"
|
||||||
ansible.builtin.command: losetup --find --show -P /root/image.img
|
ansible.builtin.command: losetup --find --show -P /root/image.img
|
||||||
register: loop_device
|
register: xfs_project_quotas_loop_device
|
||||||
changed_when: "'/dev/loop' in loop_device.stdout"
|
changed_when: "'/dev/loop' in xfs_project_quotas_loop_device.stdout"
|
||||||
|
|
||||||
- name: Get all loop devices
|
- name: Get all loop devices
|
||||||
ansible.builtin.command: losetup -a
|
ansible.builtin.command: losetup -a
|
||||||
register: losetup_out
|
register: xfs_project_quotas_losetup_out
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Find line with /root/image.img
|
- name: Find line with /root/image.img
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
matched_line: "{{ losetup_out.stdout_lines
|
xfs_project_quotas_matched_line: "{{ xfs_project_quotas_losetup_out.stdout_lines
|
||||||
| select('search', '/root/image.img')
|
| select('search', '/root/image.img')
|
||||||
| list
|
| list
|
||||||
| first
|
| first
|
||||||
@@ -39,13 +39,13 @@
|
|||||||
|
|
||||||
- name: Extract loop device name (/dev/loopN)
|
- name: Extract loop device name (/dev/loopN)
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
loop_dev: "{{ matched_line | regex_search('(/dev/loop[0-9]+)', '\\1') | default('') }}"
|
xfs_project_quotas_loop_dev: "{{ xfs_project_quotas_matched_line | regex_search('(/dev/loop[0-9]+)', '\\1') | default('') }}"
|
||||||
|
|
||||||
- name: Debug result
|
- name: Debug result
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "/root/image.img is linked to {{ loop_dev[0] }}"
|
msg: "/root/image.img is linked to {{ xfs_project_quotas_loop_dev[0] }}"
|
||||||
when: loop_dev != ''
|
when: xfs_project_quotas_loop_dev != ''
|
||||||
|
|
||||||
- name: "Quotas | Ensure xfsprogs package is installed"
|
- name: "Quotas | Ensure xfsprogs package is installed"
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name: xfsprogs
|
name: xfsprogs
|
||||||
@@ -54,10 +54,10 @@
|
|||||||
cache_valid_time: 3600
|
cache_valid_time: 3600
|
||||||
|
|
||||||
- name: Make xfs filesystem
|
- name: Make xfs filesystem
|
||||||
ansible.builtin.filesystem:
|
community.general.filesystem:
|
||||||
fstype: xfs
|
fstype: xfs
|
||||||
dev: "{{ loop_dev[0] }}"
|
dev: "{{ xfs_project_quotas_loop_dev[0] }}"
|
||||||
|
|
||||||
- name: Mount xfs virtual disk
|
- name: Mount xfs virtual disk
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
path: /mnt
|
path: /mnt
|
||||||
|
|||||||
@@ -8,6 +8,6 @@
|
|||||||
tasks:
|
tasks:
|
||||||
- name: Check XFS project quotas on /mnt
|
- name: Check XFS project quotas on /mnt
|
||||||
ansible.builtin.command: xfs_quota -x -c 'report -p' /mnt
|
ansible.builtin.command: xfs_quota -x -c 'report -p' /mnt
|
||||||
register: quota_output
|
register: xfs_project_quotas_quota_output
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: "'Project quota on /mnt' not in quota_output.stdout"
|
failed_when: "'Project quota on /mnt' not in xfs_project_quotas_quota_output.stdout"
|
||||||
|
|||||||
@@ -12,10 +12,10 @@
|
|||||||
- /etc/projid
|
- /etc/projid
|
||||||
ansible.builtin.stat:
|
ansible.builtin.stat:
|
||||||
path: "{{ item }}"
|
path: "{{ item }}"
|
||||||
register: proj_files
|
register: xfs_project_quotas_proj_files
|
||||||
|
|
||||||
- name: Create missing files
|
- name: Create missing files
|
||||||
loop: "{{ proj_files.results }}"
|
loop: "{{ xfs_project_quotas_proj_files.results }}"
|
||||||
when: not item.stat.exists
|
when: not item.stat.exists
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: "{{ item.invocation.module_args.path }}"
|
path: "{{ item.invocation.module_args.path }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user