Refinements
All checks were successful
Ansible Code Pipeline / Ansible-Development-Pipeline (ansible-dev-fedora) (push) Successful in 9s

This commit is contained in:
2025-08-18 13:13:59 -04:00
parent 33171ab091
commit cbe905fb4c

View File

@ -5,18 +5,19 @@
gather_facts: false gather_facts: false
# With NFS share(s) being in a hung state, we cannot utilize `gather_facts` # With NFS share(s) being in a hung state, we cannot utilize `gather_facts`
# as that too hangs when it tries to figure out the current mounts on the # here as that too will hang -- We instead use command/set_fact to build
# system # the needed NFS mount list.
tasks: tasks:
- name: Check for mounted NFS shares # noqa: command-instead-of-module - name: Check for mounted NFS shares # noqa: command-instead-of-module
ansible.builtin.command: mount -t nfs,nfs4 ansible.builtin.command: mount -t nfs,nfs4
register: nfs_mounts_result register: lazy_reboot_nfs_mounts
changed_when: false changed_when: false
failed_when: nfs_mounts_result['rc'] not in [0, 32] failed_when: lazy_reboot_nfs_mounts['rc'] not in [0, 32]
- name: Create a list of NFS mount points - name: Create a list of NFS mount points
ansible.builtin.set_fact: ansible.builtin.set_fact:
nfs_mount_list: "{{ nfs_mounts_result['stdout_lines'] | map('split') | map(attribute=2) | list }}" lazy_reboot_nfs_list:
"{{ lazy_reboot_nfs_mounts['stdout_lines'] | map('split') | map(attribute=2) | list }}"
- name: Verify mount status and reboot host - name: Verify mount status and reboot host
block: block:
@ -24,16 +25,16 @@
ansible.builtin.command: "ls {{ item }}" ansible.builtin.command: "ls {{ item }}"
timeout: 5 timeout: 5
changed_when: false changed_when: false
register: r_verify_mounts register: r_lazy_reboot_verify_mounts
loop: "{{ nfs_mount_list }}" loop: "{{ lazy_reboot_nfs_list }}"
loop_control: loop_control:
label: "{{ item }}" label: "{{ item }}"
rescue: rescue:
- name: Group shares that failed check - name: Group shares that failed status check
ansible.builtin.set_fact: ansible.builtin.set_fact:
failed_nfs_shares: lazy_reboot_failed_shares:
"{{ r_verify_mounts['results'] | selectattr('failed') | map(attribute='item') | list }}" "{{ r_lazy_reboot_verify_mounts['results'] | selectattr('failed') | map(attribute='item') | list }}"
- name: Lazily unmount the failed shares - name: Lazily unmount the failed shares
ansible.builtin.command: "umount -f -l {{ item }}" ansible.builtin.command: "umount -f -l {{ item }}"
@ -41,7 +42,7 @@
register: r_lazy_unmount register: r_lazy_unmount
async: 30 async: 30
poll: 0 poll: 0
loop: "{{ failed_nfs_shares }}" loop: "{{ lazy_reboot_failed_shares }}"
loop_control: loop_control:
label: "{{ item }}" label: "{{ item }}"