On Sun, 26 Apr 2020 23:18:40 -0700 (PDT) דודו דודו <[email protected]> wrote:
> 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
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/20200427090526.31d66048%40gmail.com.
pgpgKqgwiexG2.pgp
Description: OpenPGP digital signature
