Specify changed_when for shell commands

This commit is contained in:
2024-10-28 19:20:05 +01:00
parent 5312ec8cc6
commit e37b5a535b
9 changed files with 71 additions and 1 deletions

View File

@@ -17,10 +17,14 @@
- name: Enable quotas on Btrfs filesystem
ansible.builtin.command: btrfs quota enable /mnt
changed_when: result.rc == 0
register: result
- name: Make root subvolumes
when: cis | bool or item.subvol not in ['var_log', 'var_log_audit']
ansible.builtin.command: btrfs su cr /mnt/{{ '@' if item.subvol == 'root' else '@' + item.subvol }}
changed_when: result.rc == 0
register: result
loop:
- { subvol: root }
- { subvol: home }
@@ -31,6 +35,8 @@
- name: Set quotas for subvolumes
when: cis | bool or item.subvol not in ['var_log', 'var_log_audit']
ansible.builtin.command: btrfs qgroup limit {{ item.quota }} /mnt/{{ '@' if item.subvol == 'root' else '@' + item.subvol }}
changed_when: result.rc == 0
register: result
loop:
- { subvol: home, quota: 2G }

View File

@@ -15,6 +15,8 @@
- name: Remove Unsupported features for older Systems
when: (os | lower in ['almalinux', 'debian11', 'rhel8', 'rhel9', 'rocky', 'ubuntu-lts']) and (cis | bool or item.lv not in ['var_log', 'var_log_audit'])
ansible.builtin.command: tune2fs -O "^orphan_file,^metadata_csum_seed" "/dev/sys/{{ item.lv }}"
changed_when: result.rc == 0
register: result
loop:
- { lv: root }
- { lv: home }

View File

@@ -4,6 +4,8 @@
- name: Prepare partitions
failed_when: false
ansible.builtin.command: "{{ item.cmd }}"
changed_when: result.rc == 0
register: result
loop:
- { cmd: umount -l /mnt }
- { cmd: vgremove -f sys }