-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnfs-playbook.yml
More file actions
executable file
·105 lines (88 loc) · 2.64 KB
/
Copy pathnfs-playbook.yml
File metadata and controls
executable file
·105 lines (88 loc) · 2.64 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
- hosts: localhost
become: yes
tasks:
- name: Get worker1 IP
become: yes
become_user: root
shell: grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' hosts | awk 'FNR == 2 {print}'
register: worker1
- name: Get database IP
become: yes
become_user: root
shell: grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' hosts | awk 'FNR == 5 {print}'
register: database
- hosts: database
become: yes
tasks:
- name: Install NFS service
apt:
name: nfs-kernel-server
state: present
update_cache: true
- name: Create shared volume directory ghidra
file:
path: /mnt/ghidradb
state: directory
mode: 0777
- name: Create shared volume directory autopsy
file:
path: /mnt/autopsy
state: directory
mode: 0775
- debug:
msg: "Found worker1 ip to be: {{ hostvars['localhost']['worker1'].stdout }}"
- name: Add permissions for worker1 in NFS exports
become: yes
become_user: root
lineinfile:
dest: /etc/exports
line: "/mnt/ghidradb {{ hostvars['localhost']['worker1'].stdout }}(rw,sync,no_subtree_check)"
- name: Add permissions for autopsy in NFS exports
become: yes
become_user: root
lineinfile:
dest: /etc/exports
line: "/mnt/autopsy *(rw,sync,no_subtree_check)"
- become: yes
become_user: root
shell: exportfs -v
register: result
- debug:
var: result
verbosity: 2
- name: Reload NFS exports
become: yes
become_user: root
shell: exportfs -ra
- name: Restart NFS service
become: yes
become_user: root
shell: systemctl restart nfs-kernel-server
# Install apt install nfs-common and mount to database ip
- hosts: worker1
become: yes
tasks:
- name: Install nfs-common
apt:
name: nfs-common
state: present
force: yes
- name: Create shared volume directory
file:
path: /ghidra/server
state: directory
mode: 0775
- debug:
msg: "Found database ip to be: {{ hostvars['localhost']['database'].stdout }}"
- name: Mount nfs ghidra directory
mount:
src: "{{ hostvars['localhost']['database'].stdout }}:/mnt/ghidradb"
path: "/ghidra/server"
fstype: nfs
state: mounted
# - name: Enable automount on boot
# become: yes
# become_user: root
# lineinfile:
# dest: /etc/fstab
# line: "{{ hostvars['localhost']['database'].stdout }}:/mnt/ghidra /ghidra/server nfs rw 0 0"