24 lines
811 B
YAML
24 lines
811 B
YAML
---
|
|
- name: Gather NFS mounts without using Ansible facts
|
|
hosts: temp
|
|
gather_facts: false
|
|
|
|
tasks:
|
|
- name: Check for mounted NFS shares 🔎 # noqa: command-instead-of-module
|
|
ansible.builtin.command: mount -t nfs,nfs4
|
|
register: nfs_mounts_result
|
|
changed_when: false
|
|
failed_when: nfs_mounts_result.rc not in [0, 32]
|
|
|
|
- name: Debug nfs_mounts_result 🔎
|
|
ansible.builtin.debug:
|
|
msg: "{{ nfs_mounts_result }}"
|
|
|
|
- name: Create a list of NFS mount points from command output 📝
|
|
ansible.builtin.set_fact:
|
|
nfs_mount_list: "{{ nfs_mounts_result.stdout_lines | map('split') | map(attribute=2) | list }}"
|
|
|
|
- name: Display the discovered NFS mount points ✅
|
|
ansible.builtin.debug:
|
|
msg: "Discovered NFS mounts: {{ nfs_mount_list }}"
|