From 640a89292031105ee4778f04f1fe9e75a7724308 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Wed, 5 Jan 2022 14:55:13 +0100 Subject: [PATCH] Feat: shares with autofs --- roles/dotfiles/defaults/main.yml | 3 +++ roles/dotfiles/files/autofs.nas | 2 ++ roles/dotfiles/tasks/arch.yml | 2 -- roles/dotfiles/tasks/home_mounts.yml | 18 ++++++++++++++++++ roles/dotfiles/tasks/main.yml | 3 +++ 5 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 roles/dotfiles/files/autofs.nas create mode 100644 roles/dotfiles/tasks/home_mounts.yml diff --git a/roles/dotfiles/defaults/main.yml b/roles/dotfiles/defaults/main.yml index aa4801c..fee5eb8 100644 --- a/roles/dotfiles/defaults/main.yml +++ b/roles/dotfiles/defaults/main.yml @@ -3,3 +3,6 @@ me: username: 'user1' config2stow: ["nvim", "tmux", "zsh"] + +autofs: + - host: nas diff --git a/roles/dotfiles/files/autofs.nas b/roles/dotfiles/files/autofs.nas new file mode 100644 index 0000000..ecee41e --- /dev/null +++ b/roles/dotfiles/files/autofs.nas @@ -0,0 +1,2 @@ +Nas_commun -rw,soft,intr,rsize=8192,wsize=8192 nas:/mnt/DocNas/Commun +Nas_perso -rw,soft,intr,rsize=8192,wsize=8192 nas:/mnt/DocNas/Benjamin diff --git a/roles/dotfiles/tasks/arch.yml b/roles/dotfiles/tasks/arch.yml index 1f088c7..2a8502b 100644 --- a/roles/dotfiles/tasks/arch.yml +++ b/roles/dotfiles/tasks/arch.yml @@ -3,12 +3,10 @@ community.general.pacman: name: stow state: present - update_cache: yes become: true - name: Install git community.general.pacman: name: git state: present - update_cache: yes become: true diff --git a/roles/dotfiles/tasks/home_mounts.yml b/roles/dotfiles/tasks/home_mounts.yml new file mode 100644 index 0000000..eae6f6d --- /dev/null +++ b/roles/dotfiles/tasks/home_mounts.yml @@ -0,0 +1,18 @@ +--- +- name: Create NAS share directory + file: + path: "/media/{{ item.host }}" + state: directory + with_items: "{{ autofs }}" + +- name: Activate NAS shares for autofs + lineinfile: + path: /etc/autofs/auto.master + line: "/media/{{ item.host }} /etc/autofs/auto.{{ item.host }} --timeout=60 --browse" + with_items: "{{ autofs }}" + +- name: NAS autofs config file + template: + src: "files/autofs.{{ item.host }}" + dest: "/etc/autofs/auto.{{ item.host }}" + with_items: "{{ autofs }}" diff --git a/roles/dotfiles/tasks/main.yml b/roles/dotfiles/tasks/main.yml index a9f381f..fc01b1c 100644 --- a/roles/dotfiles/tasks/main.yml +++ b/roles/dotfiles/tasks/main.yml @@ -22,6 +22,9 @@ become: true become_user: "{{ me.username}}" +- name: home mounts + import_tasks: home_mounts.yml + - name: Gnome config import_tasks: gnome.yml become: true