Greetings, folks!
I’m trying to have one single source-of-truth for file share info and mount individual shares on different servers depending on need.
Give a list of “these servers get these shares, those get those” and from that list loop over what to configure and mount.
I’ve been trying to use some magic via a ‘when’ conditional to configure and mount but nothing has gelled.
Suggestions would be greatly appreciated.
Thank you for your time and have a wonderful rest of your day!
- mr. tim
Example setup…
vars:
app_server_mounts:
- share0
- share2
utility_server_mounts:
- share2
cifs_file_share_mounts:
-
path: /mnt/share0
src_host: nas.example.com
src_path: share0
fstype: cifs
opts: sec=ntlmsspi,vers=3.0,rsize=61440,wsize=65536
state: mounted -
path: /mnt/share1
src_host: nas.example.com
src_path: share1
fstype: cifs
opts: sec=ntlmsspi,vers=3.0,rsize=61440,wsize=65536
state: mounted -
path: /mnt/share2
src_host: nas.example.com
src_path: share2
fstype: cifs
opts: sec=ntlmsspi,vers=3.0,rsize=61440,wsize=65536
state: mounted
tasks:
- name: Mount CIFS file shares
mount:
path: “{{ item.path }}”
src: “//{{ item.src_host }}/{{ item.src_path }}”
fstype: cifs
opts: “{{ item.opts }}”
state: “{{ item.state | default( ‘mounted’ ) }}”
with_items: “{{ cifs_file_share_mounts }}”