autofs: set the mount point ownership.
This commit is contained in:
parent
315acd9c9f
commit
b1b610e133
|
@ -66,7 +66,16 @@ autofs_packages_el:
|
||||||
|
|
||||||
# path: without the initial /
|
# path: without the initial /
|
||||||
autofs_maps: []
|
autofs_maps: []
|
||||||
# - { map_name: 'data', mountpoint_prefix: '/', path: 'data', nfs_server: 'nfs.example.com', remote_export: '/export', is_home: False }
|
# - map_name: 'data'
|
||||||
|
# mountpoint_prefix: '/'
|
||||||
|
# path: 'data'
|
||||||
|
# nfs_server: 'nfs.example.com'
|
||||||
|
# remote_export: '/export'
|
||||||
|
# is_home: false
|
||||||
|
# force_ownership: false
|
||||||
|
# owner_uid: 1000
|
||||||
|
# owner_gid: 1000
|
||||||
|
# permissions: "0750"
|
||||||
|
|
||||||
nfs_server_enabled: false
|
nfs_server_enabled: false
|
||||||
nfs_server_ganesha_enabled: '{{ nfs_server_enabled }}'
|
nfs_server_ganesha_enabled: '{{ nfs_server_enabled }}'
|
||||||
|
|
|
@ -2,3 +2,8 @@
|
||||||
- name: Netplan Apply
|
- name: Netplan Apply
|
||||||
ansible.builtin.command:
|
ansible.builtin.command:
|
||||||
cmd: netplan apply
|
cmd: netplan apply
|
||||||
|
|
||||||
|
- name: Restart autofs
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: autofs
|
||||||
|
state: restarted
|
||||||
|
|
110
tasks/autofs.yml
110
tasks/autofs.yml
|
@ -1,36 +1,46 @@
|
||||||
---
|
---
|
||||||
- name: Install and configure autofs on Ubuntu/Debian
|
- name: autofs | Install and configure autofs on Ubuntu/Debian
|
||||||
block:
|
|
||||||
- name: Install the autofs packages on Ubuntu/Debian
|
|
||||||
apt: pkg={{ autofs_packages_deb }} state=present cache_valid_time=1800
|
|
||||||
|
|
||||||
when: ansible_distribution_file_variety == "Debian"
|
when: ansible_distribution_file_variety == "Debian"
|
||||||
tags: [ 'nfs', 'autofs' ]
|
tags: ['nfs', 'autofs']
|
||||||
|
|
||||||
- name: Install and configure autofs on EL
|
|
||||||
block:
|
block:
|
||||||
- name: Install the autofs packages on EL
|
- name: autofs | Install the autofs packages on Ubuntu/Debian
|
||||||
yum: pkg={{ autofs_packages_el }} state=present
|
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"
|
when: ansible_distribution_file_variety == "RedHat"
|
||||||
tags: [ 'nfs', 'autofs' ]
|
tags: ['nfs', 'autofs']
|
||||||
|
|
||||||
- name: Stop autofs if it is a 'hard' reconfiguration
|
|
||||||
block:
|
block:
|
||||||
- name: Stop autofs
|
- name: autofs | Install the autofs packages on EL
|
||||||
service: name=autofs state=stopped
|
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
|
when: autofs_hard_reconfig is defined and autofs_hard_reconfig
|
||||||
|
|
||||||
tags: [ 'nfs', 'autofs', 'autofs_conf' ]
|
- name: autofs | Configure autofs and its maps
|
||||||
|
tags: ['nfs', 'autofs', 'autofs_conf']
|
||||||
- name: Configure autofs and its maps
|
|
||||||
block:
|
block:
|
||||||
- name: Create the mount points
|
- name: autofs | Create the mount points
|
||||||
file: dest={{ item.mountpoint_prefix }} state=directory owner=root group=root mode=0755
|
ansible.builtin.file:
|
||||||
with_items: '{{ autofs_maps }}'
|
dest: "{{ item.mountpoint_prefix }}"
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0755"
|
||||||
|
loop: '{{ autofs_maps }}'
|
||||||
|
|
||||||
- name: setup idmap.conf
|
- name: autofs | Setup idmap.conf
|
||||||
ini_file:
|
community.general.ini_file:
|
||||||
path: /etc/idmapd.conf
|
path: /etc/idmapd.conf
|
||||||
section: '{{ item.section }}'
|
section: '{{ item.section }}'
|
||||||
option: '{{ item.option }}'
|
option: '{{ item.option }}'
|
||||||
|
@ -39,11 +49,11 @@
|
||||||
owner: 'root'
|
owner: 'root'
|
||||||
group: 'root'
|
group: 'root'
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
create: no
|
create: false
|
||||||
loop: '{{ idmap_conf_options }}'
|
loop: '{{ idmap_conf_options }}'
|
||||||
|
|
||||||
- name: setup autofs.conf
|
- name: autofs | Setup autofs.conf
|
||||||
ini_file:
|
community.general.ini_file:
|
||||||
path: /etc/autofs.conf
|
path: /etc/autofs.conf
|
||||||
section: '{{ item.section }}'
|
section: '{{ item.section }}'
|
||||||
option: '{{ item.option }}'
|
option: '{{ item.option }}'
|
||||||
|
@ -52,23 +62,43 @@
|
||||||
owner: 'root'
|
owner: 'root'
|
||||||
group: 'root'
|
group: 'root'
|
||||||
mode: '0644'
|
mode: '0644'
|
||||||
create: no
|
create: false
|
||||||
loop: '{{ autofs_conf_options }}'
|
loop: '{{ autofs_conf_options }}'
|
||||||
|
|
||||||
- name: Install the autofs master configuration
|
- name: autofs | Install the autofs master configuration
|
||||||
template: src=auto.master.j2 dest=/etc/auto.master owner=root group=root mode=0644
|
ansible.builtin.template:
|
||||||
register: reg_autofs_master_conf
|
src: auto.master.j2
|
||||||
|
dest: /etc/auto.master
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
notify: Restart autofs
|
||||||
|
|
||||||
- name: Install the autofs map files
|
- name: autofs | Install the autofs map files
|
||||||
template: src=auto.data.j2 dest=/etc/auto.{{ item.map_name }} owner=root group=root mode=0644
|
ansible.builtin.template:
|
||||||
with_items: '{{ autofs_maps }}'
|
src: auto.data.j2
|
||||||
register: autofs_conf
|
dest: "/etc/auto.{{ item.map_name }}"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
loop: '{{ autofs_maps }}'
|
||||||
|
notify: Restart autofs
|
||||||
|
|
||||||
- name: Ensure that autofs is enabled and running
|
- name: autofs | Ensure that autofs is enabled and running
|
||||||
service: name=autofs state=started enabled=yes
|
ansible.builtin.service:
|
||||||
|
name: autofs
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
|
||||||
- name: Restart autofs if the configuration changed
|
- name: autofs | Force a restart of autofs after a configuration change
|
||||||
service: name=autofs state=restarted
|
ansible.builtin.meta: flush_handlers
|
||||||
when: reg_autofs_master_conf is changed
|
tags: ['nfs', 'autofs', 'autofs_conf']
|
||||||
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue