- block:
  - name: AUTOMOUNT | install packages
    apt:
      pkg: autofs
      state: present
      update_cache: yes
      cache_valid_time: 3600

  - name: AUTOMOUNT | Enable autofs
    service:
      name: autofs
      state: started
      enabled: yes

  - name: AUTOMOUNT | create auto.master
    template:
      src: auto.master
      dest: /etc/auto.master
      owner: root
      group: root
      mode: u=rw,g=r,o=r
    notify: restart autofs

  - name: AUTOMOUNT | create map-files
    template:
      src: auto.sub.template
      dest: /etc/auto.{{ item.path | replace( '/', '-' )}}
      owner: root
      group: root
      mode: u=rw,g=r,o=r
    notify: restart autofs
    with_items: "{{ autofs }}"

  - name: AUTOMOUNT | create map root dirs
    file:
      path: "{{ item.path }}"
      owner: root
      group: root
      mode: 0755
      state: directory
    with_items: "{{ autofs }}"
  become: yes
  when: ansible_virtualization_type != "docker"
  tags:
    - autofs
