Skip to content

Commit c1065b3

Browse files
committed
add manila to compute script
1 parent 36de796 commit c1065b3

File tree

3 files changed

+223
-7
lines changed

3 files changed

+223
-7
lines changed

ansible/roles/compute_init/files/compute-init.yml

Lines changed: 166 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,55 @@
55
become: yes
66
vars:
77
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: []
1057

1158
tasks:
1259
- name: Configure resolve.conf
@@ -34,6 +81,7 @@
3481
state: reloaded
3582
when: _copy_nm_config.changed | default(false)
3683

84+
3785
- name: Mount /etc/hosts on compute nodes
3886
block:
3987
- name: Ensure the mount directory exists
@@ -42,18 +90,131 @@
4290
state: directory
4391
mode: 0755
4492

45-
- name: Mount NFS export
93+
- name: Mount /mnt/hosts
4694
mount:
4795
path: /mnt/hosts
48-
src: "{{ vars.control_node_ip }}:{{ nfs_export }}"
96+
src: "{{ vars.control_node_ip }}:{{ nfs_export_hosts }}"
4997
fstype: nfs
5098
opts: rw,sync
5199
state: mounted
52100

53-
- name: Copy /exports/hosts contents to /etc/hosts
101+
- name: Copy /mnt/hosts/hosts contents to /etc/hosts
54102
copy:
55103
src: /mnt/hosts/hosts
56104
dest: /etc/hosts
57105
owner: root
58106
group: root
59107
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"

ansible/roles/compute_init/tasks/main.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
mode: 0644
1818
loop:
1919
- ../../resolv_conf/templates/resolv.conf.j2
20+
- ../../stackhpc.os-manila-mount/templates/ceph.conf.j2
21+
- ../../stackhpc.os-manila-mount/templates/ceph.keyring.j2
2022

2123
- name: Ensure files directory exists
2224
file:
@@ -36,6 +38,52 @@
3638
loop:
3739
- ../../resolv_conf/files/NetworkManager-dns-none.conf
3840

41+
- name: Ensure library directory exists
42+
file:
43+
path: /etc/ansible-init/library
44+
state: directory
45+
owner: root
46+
group: root
47+
mode: 0644
48+
49+
- name: Inject files
50+
copy:
51+
src: '{{ item }}'
52+
dest: '/etc/ansible-init/library/{{ item | basename }}'
53+
owner: root
54+
group: root
55+
mode: 0644
56+
loop:
57+
- ../../basic_users/library/terminate_user_sessions.py
58+
- ../../stackhpc.os-manila-mount/library/os_manila_share.py
59+
60+
- name: Ensure filter_plugins directory exists
61+
file:
62+
path: /etc/ansible-init/filter_plugins
63+
state: directory
64+
owner: root
65+
group: root
66+
mode: 0644
67+
68+
- name: Inject filter_plugins
69+
copy:
70+
src: '{{ item }}'
71+
dest: '/etc/ansible-init/filter_plugins/{{ item | basename }}'
72+
owner: root
73+
group: root
74+
mode: 0644
75+
loop:
76+
- ../../basic_users/filter_plugins/filter_keys.py
77+
78+
- name: Add filter_plugins ansible.cfg
79+
lineinfile:
80+
path: /etc/ansible-init/ansible.cfg
81+
line: "filter_plugins = /etc/ansible-init/filter_plugins"
82+
state: present
83+
owner: root
84+
group: root
85+
mode: 0644
86+
3987
- name: Inject compute initialisation playbook
4088
copy:
4189
src: compute-init.yml

environments/common/inventory/group_vars/all/nfs.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ nfs_configurations:
1818

1919
- comment: Export /etc/hosts copy from Slurm control node
2020
nfs_enable:
21-
server: "{{ inventory_hostname in groups['control'] }}"
21+
server: "{{ inventory_hostname in groups['control'] }}"
2222
clients: false
23-
nfs_export: "/exports/hosts" # control node has to copy in /etc/hosts to here
23+
nfs_export: "/exports/hosts" # control node has to copy in /etc/hosts to here
24+
25+
- comment: Export cluster info from control node
26+
nfs_enable:
27+
server: "{{ inventory_hostname in groups['control']}}"
28+
clients: "{{ inventory_hostname in groups['cluster'] and inventory_hostname not in groups['control'] }}"
29+
nfs_server: "{{ nfs_server_default }}"
30+
nfs_export: "/exports/cluster"

0 commit comments

Comments
 (0)