actually you might also want to do it this way
---
- hosts: all
gather_facts: no
vars:
- mount_options:
"/home": "defaults"
"/var": "defaults,nosuid"
"/": "defaults"
tasks:
- name: Secure Mount options
mount: name={{ item.mount }} src={{ item.device }} state=present fstype
={{ item.fstype }} opts={{ mount_options[item.mount] | default(item.options)
}}
with_items: ansible_mounts
what i did here is drop the "when" check and instead used default filter so
it'd fallback to the default mount options if it didn't find options for
that specific mount in your "mount_options" variable, both examples are
usable and depends on your use case.
Good luck
On Saturday, August 2, 2014 9:05:07 AM UTC+2, [email protected] wrote:
>
> Friends,
>
> I'd like to iterate over ansible_mounts and set custom options for /some/
> mount points, like so
>
> /var: defaults,nosuid
> /home: defaults,nosuid,nodev
> /: defaults
>
> - name: Secure Mount options
> mount: name={{ item.mount }} src='{{ item.device }}' state=present
> fstype={{ item.fstype }} opts={{ ??? }}
> with_items: ansible_mounts
>
> How can I combine the list of vars within my loop. So that opts= is filled
> with the value looked up depending on the mount point?
>
> Thanks for any pointers!
> Stephan
>
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/7c0ca6ac-0902-4549-b985-2015457a0443%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.