Hi , 

That's helpful, but is there an option to match partial string ?

On Monday, April 27, 2020 at 9:18:40 AM UTC+3, דודו דודו wrote:
>
> I have a task that mounts devices in a Linux machine.
> I wish to run the task only if the device is not mounted, therefore I'm 
> running a mount command and save the output in a register. 
>
> On the mount task, I'm trying to use *when *by searching the device in 
> the register output - and I'm failing to do so.
> 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"
>
>
>
>
> *Register output *
>
>
>  
> sysfs\nproc\ndevtmpfs\nsecurityfs\ntmpfs\ndevpts\ntmpfs\ntmpfs\ncgroup\npstore\ncgroup\ncgroup\ncgroup\ncgroup\ncgroup\ncgroup\ncgroup\ncgroup\ncgroup\ncgroup\nconfigfs\n/dev/mapper/rhel-root\nselinuxfs\nsystemd-1\ndebugfs\nmqueue\nhugetlbfs\n/dev/sda1\n/dev/mapper/rhel-home\ntmpfs\n/
> *dev/sdb1*\n/dev/sdc1\n/dev/sdd1"
>
>

-- 
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/0f0515cb-3c76-4649-b3d1-150ab31d70cb%40googlegroups.com.

Reply via email to