--- - name: autofs | Install and configure autofs on Ubuntu/Debian when: ansible_distribution_file_variety == "Debian" tags: ['nfs', 'autofs'] block: - name: autofs | Install the autofs packages on Ubuntu/Debian ansible.builtin.apt: pkg: "{{ autofs_packages_deb }}" state: present cache_valid_time: 1800 - name: autofs | Install and configure autofs on EL when: ansible_distribution_file_variety == "RedHat" tags: ['nfs', 'autofs'] block: - name: autofs | Install the autofs packages on EL ansible.builtin.yum: pkg: "{{ autofs_packages_el }}" state: present - name: autofs | Stop autofs if it is a 'hard' reconfiguration tags: ['nfs', 'autofs', 'autofs_conf'] block: - name: autofs | Stop autofs ansible.builtin.service: name: autofs state: stopped when: autofs_hard_reconfig is defined and autofs_hard_reconfig - name: autofs | Configure autofs and its maps tags: ['nfs', 'autofs', 'autofs_conf'] block: - name: autofs | Create the mount points ansible.builtin.file: dest: "{{ item.mountpoint_prefix }}" state: directory owner: root group: root mode: "0755" loop: '{{ autofs_maps }}' - name: autofs | Setup idmap.conf community.general.ini_file: path: /etc/idmapd.conf section: '{{ item.section }}' option: '{{ item.option }}' value: '{{ item.value }}' state: '{{ item.state }}' owner: 'root' group: 'root' mode: '0644' create: false loop: '{{ idmap_conf_options }}' - name: autofs | Setup autofs.conf community.general.ini_file: path: /etc/autofs.conf section: '{{ item.section }}' option: '{{ item.option }}' value: '{{ item.value }}' state: '{{ item.state }}' owner: 'root' group: 'root' mode: '0644' create: false loop: '{{ autofs_conf_options }}' - name: autofs | Install the autofs master configuration ansible.builtin.template: src: auto.master.j2 dest: /etc/auto.master owner: root group: root mode: "0644" notify: Restart autofs - name: autofs | Install the autofs map files ansible.builtin.template: src: auto.data.j2 dest: "/etc/auto.{{ item.map_name }}" owner: root group: root mode: "0644" loop: '{{ autofs_maps }}' notify: Restart autofs - name: autofs | Ensure that autofs is enabled and running ansible.builtin.service: name: autofs state: started enabled: true - name: autofs | Force a restart of autofs after a configuration change ansible.builtin.meta: flush_handlers tags: ['nfs', 'autofs', 'autofs_conf'] - name: autofs | Force the ownership of the mount point ansible.builtin.file: dest: "{{ item.item.mountpoint_prefix }}/{{ item.path }}" owner: "{{ item.owner_uid }}" group: "{{ item.owner_gid }}" mode: "{{ item.permissions }}" loop: "{{ autofs_maps }}" when: item.force_ownership is defined and item.force_ownership