playbook and role config-autofs-homes

This commit is contained in:
Ruben Blanco 2023-11-06 16:53:45 +01:00
parent dc702be5e8
commit b3c567c4ce
6 changed files with 95 additions and 0 deletions

View File

@ -0,0 +1,12 @@
---
- hosts: "{{ ip_addr }}"
become: yes
become_method: sudo
gather_facts: no
tasks:
- name: "[CONFIG AUTOFS HOMES] Install and configure AUTOFS HOMES"
import_role:
name: config-autofs-homes

View File

@ -0,0 +1 @@
* -fstype=nfs4,rw homes.static.verdnatura.es:/mnt/homes/&

View File

@ -0,0 +1 @@
/mnt/homes /etc/auto.homes --timeout=30

View File

@ -0,0 +1,13 @@
---
# restart nslcd service to apply changes
- name: restart nslcd
service:
name: "{{ nslcd_daemon }}"
state: restarted
# restart autofs service to apply changes
- name: restart autofs
service:
name: "{{ autofs_daemon }}"
state: restarted

View File

@ -0,0 +1,61 @@
---
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# install packages nfs-common , autofs , libnfs-utils , autofs-ldap
- name: install packages for autofs
apt:
name: "{{ item }}"
state: present
with_items:
- nfs-common
- autofs
- libnfs-utils
- autofs-ldap
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# create directory /mnt/homes for mount
- name: create directory /mnt/homes
ansible.builtin.file:
path: "{{ path_mnt_homes }}"
state: directory
mode: '0755'
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# add line to /etc/nsswitch.conf
- name: add line to file /etc/nsswitch.conf
lineinfile:
path: "{{ path_nsswitch }}"
line: "automount: files"
notify: restart nslcd
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# add files configured to autofs
# paso 1
- name: add file homes.autofs configured to autofs
copy:
src: homes.autofs
dest: "{{ path_home_autofs }}"
owner: root
group: root
mode: '0644'
# paso 2
- name: add file /etc/auto.homes configured to the systemd
copy:
src: auto.homes
dest: "{{ path_auto_homes }}"
owner: root
group: root
mode: '0644'
notify: restart autofs
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# enabled autofs
- name: service should start on boot
service:
name: "{{ autofs_daemon }}"
enabled: yes
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@ -0,0 +1,7 @@
---
nslcd_daemon: nslcd
autofs_daemon: autofs
path_auto_homes: /etc/auto.homes
path_home_autofs: /etc/auto.master.d/homes.autofs
path_nsswitch: /etc/nsswitch.conf
path_mnt_homes: /mnt/homes