From ffa3b5d975bc4a441393fd3191bf40cf5f88552a Mon Sep 17 00:00:00 2001 From: David Kilias Date: Mon, 9 Oct 2023 21:20:51 +0200 Subject: [PATCH] rework nfs-host role --- host_vars/plumbum.n39.eu/vars.yml | 5 +++++ roles/nfs-host/defaults/main.yml | 10 +++++----- roles/nfs-host/handlers/main.yml | 3 +++ roles/nfs-host/tasks/main.yml | 9 +++++++-- 4 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 roles/nfs-host/handlers/main.yml diff --git a/host_vars/plumbum.n39.eu/vars.yml b/host_vars/plumbum.n39.eu/vars.yml index c7eab39..1214d68 100644 --- a/host_vars/plumbum.n39.eu/vars.yml +++ b/host_vars/plumbum.n39.eu/vars.yml @@ -1,2 +1,7 @@ --- +server_admin: "admin+plumbum@netz39.de" mac: "32:A3:94:A0:23:77" +nfs_host_exports: + - directory: "/srv/nfs" + hosts: "k3s-w[0-9]+.n39.eu" + options: rw,sync,no_subtree_check \ No newline at end of file diff --git a/roles/nfs-host/defaults/main.yml b/roles/nfs-host/defaults/main.yml index 386ccf7..210a3be 100644 --- a/roles/nfs-host/defaults/main.yml +++ b/roles/nfs-host/defaults/main.yml @@ -1,8 +1,8 @@ # Defaults for nfs-host --- -nfs_host_exports: - - directory: "/srv/nfs" - hosts: "k3s-w[0-9]+.n39.eu" - options: rw,sync,no_subtree_check +nfs_host_exports: [] + # - directory: "/srv/nfs" + # hosts: "k3s-w[0-9]+.n39.eu" + # options: rw,sync,no_subtree_check -nfs_host_storage_device: "/dev/sdb" \ No newline at end of file +nfs_host_storage_device: "/dev/sdb" diff --git a/roles/nfs-host/handlers/main.yml b/roles/nfs-host/handlers/main.yml new file mode 100644 index 0000000..4cdcec5 --- /dev/null +++ b/roles/nfs-host/handlers/main.yml @@ -0,0 +1,3 @@ +--- +- name: reload nfs + command: 'exportfs -ra' diff --git a/roles/nfs-host/tasks/main.yml b/roles/nfs-host/tasks/main.yml index ceb1644..7ff864c 100644 --- a/roles/nfs-host/tasks/main.yml +++ b/roles/nfs-host/tasks/main.yml @@ -11,8 +11,9 @@ state: present name: - nfs-kernel-server + - nfs-common -- name: ensure nfs mountpoint is present +- name: ensure nfs mountpoints exist ansible.builtin.file: path: "{{ item.directory }}" state: directory @@ -25,4 +26,8 @@ ansible.builtin.template: src: templates/exports.j2 dest: "/etc/exports" -# restart nfs server + notify: reload nfs + +- name: Ensure nfs is running. + ansible.builtin.service: "name={{ nfs_server_daemon }} state=started enabled=yes" + when: nfs_host_exports|length