I actually do this very thing. I have a role that just loops through a var inside the role. That role just uses the Mount task. With a lip. The role runs off the var exists. I can dig up the structure of it may help. On my phone now.
Get Outlook for iOS<https://aka.ms/o0ukef> ________________________________ From: [email protected] <[email protected]> on behalf of Tim Shubitz <[email protected]> Sent: Friday, February 19, 2021 11:36:33 AM To: Ansible Project <[email protected]> Subject: [ansible-project] Mount file share based on variable in loop 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 }}" -- 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]<mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0bd14d3d-7c6a-49c2-96d5-6b5b57fdbd8bn%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/0bd14d3d-7c6a-49c2-96d5-6b5b57fdbd8bn%40googlegroups.com?utm_medium=email&utm_source=footer>. -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/SYBPR01MB56166B17CB50DDBE188E11CBAD859%40SYBPR01MB5616.ausprd01.prod.outlook.com.
