Execution
Date 03 Apr 2024 08:32:24 +0100
Duration 00:00:10.65
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.4
ara 1.7.1 / 1.7.2.dev2
Python 3.10.10
Summary
1 Hosts
4 Tasks
4 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/projects/RM9380/RM9380-verify-folders-on-nfs-servers.yaml

---
- name: Playbook to check if the NFS mount path exists on server
  hosts: all
  vars:
    ara_playbook_name: RM9380 check autofs version
    ara_playbook_labels:
      - RM9380
      - jelastic
      - autofs
    save_folder: /home/ssh-gateway/ansible/projects/RM9380
  tasks:
    - name: Run the mount check
      block:
        - name: Check if the host is alive
          ansible.builtin.ping:
            data: "alive"
          register: ping_result
          failed_when: "'rc' in ping_result"
        - name: Run command to check the mounts
          when: "'rc' not in ping_result"
          ansible.builtin.shell: |
            set -o pipefail
            timeout -s SIGKILL 5 ls -la "{{ src_path }}"  >/dev/null && (cat /etc/exports | grep "{{ src_path }}")
          args:
            executable: /bin/bash
          register: cmd_result
          changed_when: cmd_result.rc != 0
      rescue:
        - name: Save the stopped ones to a file
          when: "'rc' in ping_result"
          ansible.builtin.debug:
            msg: "Server down"
        - name: Save the failed ones to file
          when: "cmd_result.rc != 0"
          ansible.builtin.lineinfile:
            path: "{{ save_folder }}/no_paths_on_nfs_servers.txt"
            mode: '0640'
            create: true
            line: '{{ src_node }}:{{ dstnodename }}{{ folder }}:{{ dstnodename }}:{{ folder }}'
          delegate_to: 127.0.0.1
      always:
        - name: Print all ok
          when: cmd_result.rc == 0
          ansible.builtin.debug:
            msg: "All ok"