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

Am Samstag, 2. August 2014 19:09:31 UTC+2 schrieb Amr Ali:
>
> you need to use with_dict instead of with_items 
>
> so you vars declaration would look like :
>
> ---
> ansible_mounts:
>     mount1:
>       mount: /some/mount/point
>       device: some_device
>       fstype: some_type
>      opts: "some options here"
>     mount2:
>       mount: /another/mount/point
>       device: another_device
>       fstype: another_type
>      opts: "some other options here"
>
>
>
> And your task would look like :
>
> - name: Secure Mount options
>
>   mount: name={{ item.mount }} src='{{ item.device }}' state=present 
> fstype={{ item.fstype }} opts={{ item.opts }}
>   with_dict: ansible_mounts
>
>
>
>
>

-- 
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/bffd4a18-3815-4a8c-b1a8-9883136ab424%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to