Hi Tim,

data structure in inventory (i use AWX) so just look at
os_directory_file_items and mount_list
___

- name: kubernetes workers
    inventory: inventory1
    description:
    state: present
    children:
      - childnodes
    variables:
      os_directory_file_items:
         - name: mnt
           path: /mnt
           state: directory

         - name: plceholder1
           path: /mnt/placeholder
           state: directory

         - name: Placeholder2
           path: /mnt/Placeholder2
           state: directory

      mount_list:
        - path: '/mnt/placeholder'
          mnt_name: Placeholder1
          src: 'Server1:/volume1//Placeholder1'
          fstype: nfs
          state: mounted

        - path: /mnt/Placeholder2
          mnt_name: Placeholder2
          src: 'Server1:/volume1//Placeholder2'
          fstype: nfs
          state: mounted


___
main.yml in role
---
  - name: Create Mountpoint on OS
    mount:
       path: "{{ mount_item.path }}"
       fstab: "{{ mount_item.fstab | default(omit)}}"
       boot: "{{ mount_item.boot | default(omit)}}"
       dump: "{{ mount_item.dump | default(0)}}"
       fstype:  "{{ mount_item.fstype | default(0)}}"
       opts: "{{ mount_item.opts | default(omit)}}"
       passno: "{{ mount_item.passno | default(0)}}"
       src: "{{ mount_item.src | default('present')}}"
       state: "{{ mount_item.state | default('mounted')}}"
    loop: "{{ mount_list }}"
    loop_control:
      loop_var: mount_item
    when: mount_list is defined
___
playbook
---
- name: Configure common linux settings
  hosts: all
  roles:
    - { role: configure_common_os_directory , when: os_directory_file_items
is defined , tags: os_directory_file_settings  }
    - { role: configure_mnt , when: mount_list is defined , tags:
linux_mnt_settings  }

On Fri, 19 Feb 2021 at 13:24, Tim Shubitz <[email protected]> wrote:

>
> > On Feb 18, 2021, at 4:40 PM, Wei-Yen Tan <[email protected]> wrote:
> >
> > 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.
>
> Wei-Yen,
>   With the quickness!
>
> Looking forward to your code snippets.
>
> Thanks!
>
>
> - mr. tim
>
> --
> 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/6278ED4F-66A0-4CBA-938A-F8ED2132A4B1%40gmail.com
> .
>

-- 
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/CA%2BjXPxi5%3DrLGyt0TJf_oTdCaPMFi9ag0cgD%2B5U%3DhCsOVt%3DYiwA%40mail.gmail.com.

Reply via email to