Add support for autofs mount points.
This commit is contained in:
parent
3989706fc2
commit
9d2b9bf1c4
|
@ -12,11 +12,23 @@ locales_list:
|
||||||
- { name: 'it_IT' }
|
- { name: 'it_IT' }
|
||||||
|
|
||||||
#
|
#
|
||||||
# Define the following variables to manage additional disks and mount points
|
# Define the following variables to manage additional disks and mount points, even static nfs ones
|
||||||
additional_disks: False
|
additional_disks: False
|
||||||
disks_and_mountpoints_list: []
|
disks_and_mountpoints_list: []
|
||||||
# - { mountpoint: '/data', device: 'xvda3', fstype: 'xfs', opts: 'noatime', state: 'mounted', create_filesystem: True }
|
# - { mountpoint: '/data', device: 'xvda3', fstype: 'xfs', opts: 'noatime', state: 'mounted', create_filesystem: True }
|
||||||
|
|
||||||
|
# autofs mount points
|
||||||
|
autofs_client_mountpoint: False
|
||||||
|
autofs_packages_deb:
|
||||||
|
- autofs
|
||||||
|
|
||||||
|
autofs_packages_el:
|
||||||
|
- autofs
|
||||||
|
|
||||||
|
# path: without the initial /
|
||||||
|
autofs_maps: []
|
||||||
|
# - { map_name: 'data', mount_point_prefix: '/', path: 'data', nfs_server: 'nfs.example.com', remote_export: '/export' }
|
||||||
|
|
||||||
# tmpreaper
|
# tmpreaper
|
||||||
tmpreaper_install: False
|
tmpreaper_install: False
|
||||||
tmpreaper_protect_extra: ''
|
tmpreaper_protect_extra: ''
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
when:
|
when:
|
||||||
- additional_disks
|
- additional_disks
|
||||||
- item.create_filesystem
|
- item.create_filesystem
|
||||||
|
- item.fstype != 'nfs'
|
||||||
|
|
||||||
- name: Manage the additional file systems
|
- name: Manage the additional file systems
|
||||||
mount: name={{ item.mountpoint }} src={{ item.root_device | default('/dev') }}/{{ item.device }} fstype={{ item.fstype }} opts={{ item.opts }} state={{ item.state }}
|
mount: name={{ item.mountpoint }} src={{ item.root_device | default('/dev') }}/{{ item.device }} fstype={{ item.fstype }} opts={{ item.opts }} state={{ item.state }}
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
---
|
||||||
|
- name: 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"
|
||||||
|
tags: [ 'nfs', 'autofs' ]
|
||||||
|
|
||||||
|
- name: Install and configure autofs on EL
|
||||||
|
block:
|
||||||
|
- name: Install the autofs packages onn EL
|
||||||
|
yum: pkg={{ autofs_packages_el }} state=present
|
||||||
|
|
||||||
|
when: ansible_distribution_file_variety == "RedHat"
|
||||||
|
tags: [ 'nfs', 'autofs' ]
|
||||||
|
|
||||||
|
- name: Configure autofs and its maps
|
||||||
|
block:
|
||||||
|
- name: Create the mount points
|
||||||
|
file: dest={{ item.mountpoint_prefix }}/{{ item.path }} state=directory owner=root group=root mode=0755
|
||||||
|
with_items: '{{ autofs_maps }}'
|
||||||
|
|
||||||
|
- name: Install the autofs master configuration
|
||||||
|
template: src=auto.master.j2 dest=/etc/auto.master owner=root group=root mode=0644
|
||||||
|
register: reg_autofs_master_conf
|
||||||
|
|
||||||
|
- name: Install the autofs map files
|
||||||
|
template: src=auto.data.j2 dest=/etc/auto.{{ item.map_name }} owner=root group=root mode=0644
|
||||||
|
with_items: '{{ autofs_maps }}'
|
||||||
|
register: autofs_conf
|
||||||
|
|
||||||
|
- name: Ensure that autofs is enabled and running
|
||||||
|
service: name=autofs state=started enabled=yes
|
||||||
|
|
||||||
|
- name: Restart autofs if the configuration changed
|
||||||
|
service: name=autofs state=restarted
|
||||||
|
when: reg_autofs_master_conf is changed
|
||||||
|
|
||||||
|
tags: [ 'nfs', 'autofs' ]
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
- import_tasks: http_client_proxy.yml
|
- import_tasks: http_client_proxy.yml
|
||||||
- import_tasks: additional_disks.yml
|
- import_tasks: additional_disks.yml
|
||||||
when: additional_disks
|
when: additional_disks
|
||||||
|
- import_tasks: autofs.yml
|
||||||
|
when: autofs_client_mountpoint
|
||||||
- import_tasks: tmpreaper.yml
|
- import_tasks: tmpreaper.yml
|
||||||
- import_tasks: trusted_ca.yml
|
- import_tasks: trusted_ca.yml
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
{{ item.path }} / {{ item.nfs_server }}:{{ item.remote_export }}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{% for maps in autofs_maps %}
|
||||||
|
{{ maps.mountpoint_prefix }} /etc/auto.{{ maps.map_name }}
|
||||||
|
{% endfor %}
|
Loading…
Reference in New Issue