Mount home directories

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2021-05-24 20:51:07 +02:00
parent 0a85cd22ff
commit 3fedc63db3
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
6 changed files with 65 additions and 0 deletions

4
group_vars/all/home.yml Normal file
View File

@ -0,0 +1,4 @@
---
glob_home:
ip: 172.16.42.1
mountpoint: /rpool/home

View File

@ -4,6 +4,7 @@
- import_playbook: apt.yml
- import_playbook: ntp.yml
- import_playbook: ldap-client.yml
- import_playbook: home.yml
- hosts: all
roles:

7
plays/home.yml Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env ansible-playbook
---
- hosts: debian
vars:
home: '{{ glob_home | combine(loc_home | default({})) }}'
roles:
- home

8
roles/home/README.md Normal file
View File

@ -0,0 +1,8 @@
# HOME-NOUNOUS
Ce rôle permet d'exporter les homes vers les différents serveurs.
## VARS
home_nounous:
ip: l'ip du serveur nfs

31
roles/home/tasks/main.yml Normal file
View File

@ -0,0 +1,31 @@
---
- name: Install NFS client
apt:
update_cache: true
name:
- nfs-common
state: present
register: apt_result
retries: 3
until: apt_result is succeeded
- name: Create directory home
file:
path: /home
state: directory
owner: root
group: user
mode: 0750
- name: Deploy nfs systemd mount
template:
src: systemd/system/home.mount.j2
dest: /etc/systemd/system/home.mount
mode: 0644
- name: Load and activate nfs systemd mount
systemd:
name: home.mount
daemon_reload: true
enabled: true
state: started

View File

@ -0,0 +1,14 @@
{{ ansible_header | comment }}
[Unit]
Description=Mount home
Wants=network-online.target
After=network-online.target
[Mount]
What={{ home.ip }}:{{ home.mountpoint }}
Where=/home
Type=nfs
Options=rw,nosuid
[Install]
WantedBy=multi-user.target