Hi!
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:
- name: Secure Mount options
mount: name={{ item.mount }} src='LABEL={{ item.label }}'
state=present fstype={{ item.fs }}
opts={{ item.options }} passno={{ item.fsck }}
with_items:
- { mount: '/home', label: 'home', fs: 'ext4', fsck: '2', options: 'defaults,nosuid,nodev' }
- { mount: '/var', label: 'var', fs: 'ext4', fsck: '2', options: 'defaults,nosuid' }
- { mount: '/', label: 'root', fs: 'ext4', fsck: '1', options: 'defaults' }
- { mount: 'swap', label: 'swap', fs: 'swap', fsck: '0', options: 'defaults' }
Is that possible?
Cheers,
Stephan