My ansible script is doing a great job at putting all the mounts on any system I specify. But my intention was to install mounts dependent on subnet.
People on .35 are privileged and need acccess to special documents whereas everyone can access our public docs and apps drive.'
Does anyone know what I'm doing wrong here?
[UPDATE] After Vladimir Botka's great reply I'm nearly there. The only problem is my section here (as I've abandoned roles now):
tasks:
- name: Mount the entries in list
mount:
name: '{{ item }}'
path: '{{ item.mount_point }}'
src: '{{ item.shared_storage }}'
fstype: nfs
opts: rw
state: mounted
with_items: '{{ my_mounts }}'
Do you know why its outputting lines into fstab like this:
srvr:/docs {'mount_point':\040'/mnt/doc',\040'shared_storage':\040'srvr:/docs'} nfs rw 0 0
--- Instead Of ----
srvr:/docs /mnt/doc nfs rw 0 0
?
I tried setting path: '{{ item.mount_point.1 }}' and a few other total guesses but to no avail.
ORIGINALPLAYBOOK WAS:
---
- name: My mounts
hosts: accounting
become: yes
vars:
subnet: "{{ ansible_default_ipv4.address.split('.')[2:3] | join('.') }}"
tasks:
- debug:
msg: subnet is {{ subnet }}
roles:
- role: nfsmount
vars:
mount_point: /mnt/docs
shared_storage: bay05:/docs/spreadsheets
when: ( "subnet == '20'" ) or ( "subnet == '35'" )
- role: nfsmount
vars:
mount_point: /mnt/pub
shared_storage: cheetah:/pub
when: ( "subnet == '20'" )
name: '{{ item }}'
. See parameter path.name
is alias ofpath
. What do you want to achieve by using them both in a single task?