-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnfs.yml
58 lines (56 loc) · 1.51 KB
/
nfs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
- import_playbook: setup-requirements.yml
- name: setup nfs servers
hosts: virt-host
handlers:
- name: restart nfs server
service:
enabled: yes
name: nfs-kernel-server
state: restarted
listen: "restart nfs server"
when:
- (nfs_folders_created is changed) or (nfs_exports_created is changed)
tasks:
- name: install nfs server
apt:
install_recommends: no
name: nfs-kernel-server
state: present
update_cache: yes
- name: ensure folders to export are available
file:
group: "{{ item.group }}"
mode: "{{ item.mode }}"
owner: "{{ item.owner }}"
path: "{{ item.path }}"
recurse: no
state: directory
register: nfs_folders_created
notify: "restart nfs server"
with_items: "{{ nfs_shares }}"
- name: write exports
template:
backup: yes
dest: /etc/exports
src: exports.j2
notify: "restart nfs server"
register: nfs_exports_created
- name: log changed folders
copy:
content: "{{ nfs_folders_created | to_json }}"
dest: "{{ playbook_dir }}/nfs_folders_created.json"
delegate_to: localhost
run_once: yes
changed_when: False
when:
- nfs_folders_created is changed
- name: setup nfs clients
hosts: managers,workers
tasks:
- name: install nfs client
apt:
install_recommends: no
name: nfs-common
state: present
update_cache: yes