> The task is running even that /dev/sdb1 is included in the register
>
> *Playbook:*
>
> - name: check mount
> shell: mount | awk '{print $1}'
> register: mount
>
> - debug:
> msg: " {{ mount.stdout_lines }}"
>
> - name: Mount task 1 - create directory
> file:
> path: "{{item.mount_path}}"
> state: directory
> when: mount.stdout_lines != "/dev/sdb1"
Correct syntax is below
- name: Mount task 1 - create directory
file:
path: /dev/sdb1
state: directory
when: "'/dev/sdb1' not in mount.stdout_lines"
The code implicates a loop
- name: Mount task 1 - create directory
file:
path: "{{ item.mount_path }}"
state: directory
loop: "{{ my_list_of_mountpoints }}"
when: "item.mount_path not in mount.stdout_lines"
(Ansible module "mount" does the job.)
HTH,
-vlado