-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorage_install_tasks.yml
45 lines (44 loc) · 1.21 KB
/
storage_install_tasks.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
- name: Stop service firewalld, if started
# Note: for production environments, you want to add nfs:tcp as an exception instead
ansible.builtin.service:
name: firewalld
state: stopped
enabled: False
- name: Install nfs-utils
ansible.builtin.yum:
name:
- nfs-utils
- nfs4-acl-tools
state: present
allow_downgrade: true
- name: Create a mountable directory if it does not exist
ansible.builtin.file:
path: "{{ share }}"
state: directory
owner: root
group: root
mode: '0777'
- name: Reload nfs # noqa: no-changed-when
ansible.builtin.command: 'exportfs -ra'
- name: Enable rpcbind nfs
ansible.builtin.service:
name: "{{ item }}"
enabled: true
with_items:
- rpcbind
- nfs-server
- name: Share in /etc/exports file
ansible.builtin.lineinfile:
path: /etc/exports
state: present
line: '{{ share }} {{ options }}'
notify: NFS server restart
- name: NFS reload
ansible.builtin.systemd:
name: nfs-server
state: reloaded
- name: NFS apply change configure
ansible.builtin.command: exportfs -rav
register: initialize_nfs
failed_when: "initialize_nfs.rc not in [0, 1]"
changed_when: "'exporting' in initialize_nfs.stdout_lines"