summaryrefslogtreecommitdiffstats
path: root/ansible
diff options
context:
space:
mode:
Diffstat (limited to 'ansible')
-rw-r--r--ansible/roles/nfs/handlers/main.yml3
-rw-r--r--ansible/roles/nfs/tasks/main.yml15
-rw-r--r--ansible/roles/nfs/templates/exports.j24
3 files changed, 14 insertions, 8 deletions
diff --git a/ansible/roles/nfs/handlers/main.yml b/ansible/roles/nfs/handlers/main.yml
new file mode 100644
index 00000000..4b8deaeb
--- /dev/null
+++ b/ansible/roles/nfs/handlers/main.yml
@@ -0,0 +1,3 @@
+---
+- name: reload nfs
+ command: exportfs -ra
diff --git a/ansible/roles/nfs/tasks/main.yml b/ansible/roles/nfs/tasks/main.yml
index aca1771f..e7580b66 100644
--- a/ansible/roles/nfs/tasks/main.yml
+++ b/ansible/roles/nfs/tasks/main.yml
@@ -9,7 +9,7 @@
package:
name: "{{ item }}"
state: present
- with_items: "{{ nfs_packages[ansible_os_family] }}"
+ loop: "{{ nfs_packages[ansible_os_family] }}"
- name: Setup nfs server
block:
@@ -17,22 +17,25 @@
systemd:
name: "{{ item }}"
state: started
- with_items: "{{ nfs_services[ansible_os_family] }}"
+ enabled: true
+ loop: "{{ nfs_services[ansible_os_family] }}"
- name: Add hosts to exports
template:
src: exports.j2
dest: /etc/exports
-
- - name: Export nfs
- command: exportfs -ar
+ notify:
+ - reload nfs
when:
- "'nfs-server' in group_names"
+- name: Force notified handlers to run at this point
+ meta: flush_handlers
+
- name: Mount dockerdata-nfs
mount:
path: "{{ nfs_mount_path }}"
- src: "{{ hostvars[groups['nfs-server'].0].ansible_host }}:{{ nfs_mount_path }}"
+ src: "{{ hostvars[groups['nfs-server'].0].ansible_host | default(hostvars[groups['nfs-server'].0].inventory_hostname) }}:{{ nfs_mount_path }}"
fstype: nfs
state: mounted
when:
diff --git a/ansible/roles/nfs/templates/exports.j2 b/ansible/roles/nfs/templates/exports.j2
index 1f6956c2..c605d9b8 100644
--- a/ansible/roles/nfs/templates/exports.j2
+++ b/ansible/roles/nfs/templates/exports.j2
@@ -1,3 +1,3 @@
-{% for host in groups.kubernetes[1:] -%}
- {{ nfs_mount_path }} {{ hostvars[host].ansible_host }}(rw,sync,no_root_squash,no_subtree_check)
+{% for host in groups.kubernetes -%}
+ {{ nfs_mount_path }} {{ hostvars[host].ansible_host | default(hostvars[host].inventory_hostname) }}(rw,sync,no_root_squash,no_subtree_check)
{% endfor %}