ctucx.git: ansible-configs

My personal ansible roles and playbooks [deprecated in favor of nixos]

commit 52d72c8217b6f1b99514f8161244d5dc885a4020
parent 87ca9e1ddb8b6ca91806a3737863de745124af38
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 2 Feb 2021 10:51:43 +0100

nfsserver: add role
2 files changed, 41 insertions(+), 0 deletions(-)
A
roles/nfsserver/tasks/main.yml
|
33
+++++++++++++++++++++++++++++++++
A
roles/nfsserver/templates/exports.j2
|
8
++++++++
diff --git a/roles/nfsserver/tasks/main.yml b/roles/nfsserver/tasks/main.yml
@@ -0,0 +1,33 @@
+---
+
+#install it
+- name: "[Alpine] Install package: nfs-utils"
+  apk:
+    name: nfs-utils
+    state: present
+    update_cache: yes
+  when: 
+    - ansible_distribution == "Alpine" 
+    - services.nfsserver.enable is true
+
+# configure it 
+- name: "[Alpine] Generate /etc/exports"
+  template:
+    src: exports.j2
+    dest: /etc/exports
+    mode: 0755
+    owner:  root
+    group: root
+  when:
+    - ansible_distribution == "Alpine"  
+    - services.nfsserver.enable is true
+
+# start it 
+- name: "[OpenRC] Enable and start service: nfs"
+  service:
+    name: nfs
+    enabled: yes
+    state: started
+  when: 
+    - ansible_service_mgr == "openrc"
+    - services.nfsserver.enable is true
diff --git a/roles/nfsserver/templates/exports.j2 b/roles/nfsserver/templates/exports.j2
@@ -0,0 +1,7 @@
+#
+# !!! This file is managed by Ansible !!!
+#
+
+{% for export in services.nfsserver.exports %}
+{{ export.path }} {{ export.address }}({{ export.options }})
+{% endfor %}+
\ No newline at end of file