2022-05-26

find Mount point from cat /etc/fstab with ansible

i would create a playbook that Check Mount_points for fstype:ext related to the vars: whitelist so it will iterate through the vars to check if mount_point exists or not if it exists an output should be similar to this, else it will be ignored

/ /boot /home /opt /var /var/opt /var/tmp /var/log /var/log/audit here is my playbook which was using 'xfs' as i don't have ext in my machine. Could you advise about more efficient way to achieve the desired result

  - hosts: all
    vars:
      whitelist:
        - '/'
        - '/boot'
        - '/home'
        - '/opt'
        - '/var'
        - '/bin'
        - '/usr'  

    tasks:
      - set_fact:
          mount_point: "Liquid error: wrong number of arguments (given 1, expected 2)"
      - debug:
          var: mount_point

        loop: ""
        when: item in mount_point

TASK [set_fact] **************************************************************************************************************
ok: [ansible2]
ok: [ansible3]

TASK [debug] *****************************************************************************************************************
ok: [ansible2] => (item=/) => {
    "msg": [
        "/",
        "/boot"
    ]
}
ok: [ansible2] => (item=/boot) => {
    "msg": [
        "/",
        "/boot"
    ]
}
skipping: [ansible2] => (item=/home)
skipping: [ansible2] => (item=/opt)
skipping: [ansible2] => (item=/var)
skipping: [ansible2] => (item=/bin)
skipping: [ansible2] => (item=/usr)
ok: [ansible3] => (item=/) => {
    "msg": [
        "/boot",
        "/"
    ]
}
ok: [ansible3] => (item=/boot) => {
    "msg": [
        "/boot",
        "/"
    ]
}
skipping: [ansible3] => (item=/home)
skipping: [ansible3] => (item=/opt)
skipping: [ansible3] => (item=/var)
skipping: [ansible3] => (item=/bin)
skipping: [ansible3] => (item=/usr)

PLAY RECAP *******************************************************************************************************************
ansible2                   : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0
ansible3                   : ok=3    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0


No comments:

Post a Comment