Thanks for your help. I’m still not getting it kinda, but my initial post wasn’t really clearly formulated actually.
I actually like to iterate over the ansible_mounts object fact that has three mount points. And then use those facts to build my mount tasks, except for the mount options, which I’d like to specify myself. So in (broken) shell like pseudo code that would be something like:
for i in ansible_mounts; do
task = “mount: name={{ ansible_mount.mount }} src={{ ansible_mount.device }} state=present fstype={{ ansible:mount.fstype }}”
if ansible_mount.mount -eq ‘/var’
opts={{ defaults,nosuid }}
elseif ansible_mount.mount -eq ‘/home’
opts={{ defaults,nosuid,nodev }}
fi
done
That way, I could specify the mount options dynamically, no matter how many devices are actually present in ansible.mounts. My current solution is rather static, using with_items like so - and requires labels to be set:
didn’t realize you were using the ansible_mounts fact, i understand what you are trying to do here and i think there might be a way…
how about you try doing this :
Define a new var “mount_options” which links mount names to options predefined by you, then use it in your mount command to dynamically fill the options argument.