5
5
become : yes
6
6
vars :
7
7
control_node_ip : " 172.16.1.228"
8
- nfs_export : " /exports/hosts"
9
- resolv_conf_nameservers : []
8
+ nfs_export_hosts : " /exports/hosts"
9
+ resolv_conf_nameservers : [1.1.1.1, 8.8.8.8]
10
+
11
+ # block device (disk) on which to create the exported filesystem.
12
+ # if the disk is not defined, formatting and mounting will not be done.
13
+ nfs_disk_location :
14
+
15
+ # Path to exported filesystem mountpoint on nfs servers
16
+ nfs_export : " /exports/home"
17
+
18
+ # nfs client mount options
19
+ nfs_client_mnt_options :
20
+
21
+ # Path to mountpoint on nfs clients
22
+ nfs_client_mnt_point : " /home"
23
+ nfs_client_mnt_state : mounted
24
+
25
+ nfs_server : " {{ control_node_ip }}"
26
+
27
+
28
+ os_manila_mount_shares : []
29
+ os_manila_mount_state : mounted
30
+ os_manila_mount_opts :
31
+ - x-systemd.device-timeout=30
32
+ - x-systemd.mount-timeout=30
33
+ - noatime
34
+ - _netdev # prevents mount blocking early boot before networking available
35
+ - rw
36
+ os_manila_mount_share_info : [] # populated by lookup mode
37
+ os_manila_mount_ceph_conf_path : /etc/ceph
38
+
39
+
40
+ basic_users_manage_homedir : false
41
+
42
+ basic_users_userdefaults :
43
+ state : present
44
+ create_home : " {{ basic_users_manage_homedir }}"
45
+ generate_ssh_key : " {{ basic_users_manage_homedir }}"
46
+ ssh_key_comment : " {{ item.name }}"
47
+
48
+ test_user_password : " zXpcWyGQL7jtZnqylQra4g=="
49
+
50
+ basic_users_users :
51
+ - name : testuser # can't use rocky as $HOME isn't shared!
52
+ password : " {{ test_user_password | password_hash('sha512', 65534 | random(seed=inventory_hostname) | string) }}" # idempotent
53
+ uid : 1005
54
+ state : present
55
+
56
+ basic_users_groups : []
10
57
11
58
tasks :
12
59
- name : Configure resolve.conf
34
81
state : reloaded
35
82
when : _copy_nm_config.changed | default(false)
36
83
84
+
37
85
- name : Mount /etc/hosts on compute nodes
38
86
block :
39
87
- name : Ensure the mount directory exists
42
90
state : directory
43
91
mode : 0755
44
92
45
- - name : Mount NFS export
93
+ - name : Mount /mnt/hosts
46
94
mount :
47
95
path : /mnt/hosts
48
- src : " {{ vars.control_node_ip }}:{{ nfs_export }}"
96
+ src : " {{ vars.control_node_ip }}:{{ nfs_export_hosts }}"
49
97
fstype : nfs
50
98
opts : rw,sync
51
99
state : mounted
52
100
53
- - name : Copy /exports /hosts contents to /etc/hosts
101
+ - name : Copy /mnt/hosts /hosts contents to /etc/hosts
54
102
copy :
55
103
src : /mnt/hosts/hosts
56
104
dest : /etc/hosts
57
105
owner : root
58
106
group : root
59
107
mode : 0644
108
+
109
+
110
+ - name : NFS client mount
111
+ block :
112
+ - name : ensure mount directory exists
113
+ file :
114
+ path : " {{ nfs_client_mnt_point }}"
115
+ state : directory
116
+
117
+ - name : mount the filesystem
118
+ mount :
119
+ path : " {{ nfs_client_mnt_point }}"
120
+ src : " {{ nfs_server }}:{{ nfs_export }}"
121
+ fstype : nfs
122
+ state : " {{ nfs_client_mnt_state }}"
123
+
124
+
125
+ - name : Manila mount
126
+ block :
127
+ - name : Read manila share from nfs file
128
+ slurp :
129
+ src : " /mnt/cluster/manila_share_info.yml"
130
+ register : manila_share_info_file
131
+
132
+ - name : Parse and set fact for manila share info
133
+ set_fact :
134
+ os_manila_mount_share_info : " {{ manila_share_info_file.content | b64decode | from_yaml }}"
135
+
136
+ - name : Ensure Ceph configuration directory exists
137
+ ansible.builtin.file :
138
+ path : " {{ os_manila_mount_ceph_conf_path }}"
139
+ state : directory
140
+ mode : " 0755"
141
+ owner : root
142
+ group : root
143
+
144
+ - name : Configure ceph.conf using os_manila_mount_host
145
+ ansible.builtin.template :
146
+ src : /etc/ansible-init/templates/ceph.conf.j2
147
+ dest : " {{ os_manila_mount_ceph_conf_path }}/ceph.conf"
148
+ owner : root
149
+ group : root
150
+ mode : " 0600"
151
+
152
+ - name : Ensure mount directory exists
153
+ ansible.builtin.file :
154
+ path : " {{ item.mount_path }}"
155
+ state : directory
156
+ owner : " {{ item.mount_user | default(omit) }}"
157
+ group : " {{ item.mount_group | default(omit) }}"
158
+ mode : " {{ item.mount_mode | default(omit) }}"
159
+ loop : " {{ os_manila_mount_shares }}"
160
+ loop_control :
161
+ label : " {{ item.share_name }}"
162
+
163
+ - name : Write Ceph client keyring
164
+ ansible.builtin.template :
165
+ src : /etc/ansible-init/templates/ceph.keyring.j2
166
+ dest : " {{ os_manila_mount_ceph_conf_path }}/ceph.client.{{ item.share_user }}.keyring"
167
+ mode : " 0600"
168
+ owner : root
169
+ group : root
170
+ loop : " {{ os_manila_mount_share_info }}"
171
+ loop_control :
172
+ label : " {{ item.share_name }}"
173
+
174
+ - name : Mount the Ceph share
175
+ ansible.posix.mount :
176
+ path : " {{ item[0].mount_path }}"
177
+ src : " {{ item[1].host }}:{{ item[1].export }}"
178
+ fstype : ceph
179
+ opts : " name={{ item[1].share_user }},{{ (item[0].mount_opts | default(os_manila_mount_opts)) | join(',') }}"
180
+ # NB share_user is looked up here in case of autodetection
181
+ state : " {{ item[0].mount_state | default(os_manila_mount_state) }}"
182
+ loop : " {{ os_manila_mount_shares | zip(os_manila_mount_share_info) }}"
183
+ loop_control :
184
+ label : " {{ item[0].share_name }}"
185
+
186
+ - name : Ensure mounted directory has correct permissions
187
+ ansible.builtin.file :
188
+ path : " {{ item.mount_path }}"
189
+ state : directory
190
+ owner : " {{ item.mount_user | default(omit) }}"
191
+ group : " {{ item.mount_group | default(omit) }}"
192
+ mode : " {{ item.mount_mode | default(omit) }}"
193
+ loop : " {{ os_manila_mount_shares }}"
194
+ loop_control :
195
+ label : " {{ item.share_name }}"
196
+ when : item.mount_state | default(os_manila_mount_state) in ['mounted' or 'ephemeral']
197
+
198
+
199
+ - name : Basic users setup
200
+ block :
201
+ - name : Create groups
202
+ ansible.builtin.group : " {{ item }}"
203
+ loop : " {{ basic_users_groups }}"
204
+
205
+ - name : Create users
206
+ user : " {{ basic_users_userdefaults | combine(item) | filter_user_params() }}"
207
+ loop : " {{ basic_users_users }}"
208
+ loop_control :
209
+ label : " {{ item.name }} [{{ item.state | default('present') }}]"
210
+ register : basic_users_info
211
+
212
+ - name : Write sudo rules
213
+ blockinfile :
214
+ path : /etc/sudoers.d/80-{{ item.name}}-user
215
+ block : " {{ item.sudo }}"
216
+ create : true
217
+ loop : " {{ basic_users_users }}"
218
+ loop_control :
219
+ label : " {{ item.name }}"
220
+ when : " 'sudo' in item"
0 commit comments