So basically i want to check somehow if the /dev/xvdb1 is mounted to /var
If answer is yes:
- don't create dir
- don't copy files
- don't mount /var etc
If the answer is no:
proceed with everything
- name: check if /var is mounted shell: df -hT | grep /var register: df - name: Create /mnt/newvar directory file: path: "{{ newvar_dir }}" state: directory when: not df.stdout_lines - name: "Get UUID for partition" shell: "lsblk -no UUID /dev/xvdb1" register: volume_uuids - name: Mount /mnt/newvar to /dev/xvdb1 mount: path: "{{ newvar_dir }}" src: "UUID={{ item }}" fstype: "{{ volume_filesystem_type }}" opts: "defaults,noauto" state: mounted with_items: - "{{ volume_uuids.stdout_lines }}" when: not df.stdout_lines
Error: fatal: [x.x.x.x]: FAILED! => {"changed": true, "cmd": "df -hT | grep /var", "delta": "0:00:00.005132", "end": "2019-03-10 03:07:22.485343", "msg": "non-zero return code", "rc": 1, "start": "2019-03-10 03:07:22.480211", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}
The issue is: if there is no output from df command, ansible brakes.