Skip to content

Commit e0d0c06

Browse files
committed
support manila in compute-init
1 parent 9859d54 commit e0d0c06

File tree

4 files changed

+104
-9
lines changed

4 files changed

+104
-9
lines changed

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

Lines changed: 84 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
enable_resolv_conf: "{{ os_metadata.meta.enable_resolv_conf | default(false) | bool }}"
1111
enable_etc_hosts: "{{ os_metadata.meta.enable_etc_hosts | default(false) | bool }}"
1212
enable_nfs: "{{ os_metadata.meta.enable_nfs | default(false) | bool }}"
13+
enable_manila: "{{ os_metadata.meta.enable_manila | default(false) | bool }}"
1314

1415
# TODO: "= role defaults" - could be moved to a vars_file: on play with similar precedence effects
1516
resolv_conf_nameservers: []
@@ -23,6 +24,16 @@
2324

2425
# openhpc: no defaults required
2526

27+
os_manila_mount_shares: []
28+
os_manila_mount_ceph_conf_path: /etc/ceph
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+
2637
tasks:
2738
- block:
2839
- name: Report skipping initialization if not compute node
@@ -103,15 +114,85 @@
103114
mode: 0644
104115
when: enable_etc_hosts
105116

106-
# TODO: - name: NFS client mount
117+
# NFS client mount
107118
- name: If nfs-clients is present
108-
include_tasks: ../tasks/nfs-clients.yml
119+
include_tasks: tasks/nfs-clients.yml
109120
when:
110121
- enable_nfs
111122
- nfs_enable.clients | bool or ('nfs_enable' in item and item.nfs_enable.clients | bool)
112123
loop: "{{ nfs_configurations }}"
113124

114-
# TODO: - name: Manila mount
125+
- name: Manila mounts
126+
block:
127+
- name: Read manila share info from nfs file
128+
include_vars:
129+
file: /mnt/cluster/manila_share_info.yml
130+
no_log: true # contains secrets
131+
132+
- name: Ensure Ceph configuration directory exists
133+
ansible.builtin.file:
134+
path: "{{ os_manila_mount_ceph_conf_path }}"
135+
state: directory
136+
mode: "0755"
137+
owner: root
138+
group: root
139+
140+
- name: Configure ceph.conf using os_manila_mount_host
141+
ansible.builtin.template:
142+
src: ceph.conf.j2
143+
dest: "{{ os_manila_mount_ceph_conf_path }}/ceph.conf"
144+
owner: root
145+
group: root
146+
mode: "0600"
147+
148+
- name: Ensure mount directory exists
149+
ansible.builtin.file:
150+
path: "{{ item.mount_path }}"
151+
state: directory
152+
owner: "{{ item.mount_user | default(omit) }}"
153+
group: "{{ item.mount_group | default(omit) }}"
154+
mode: "{{ item.mount_mode | default(omit) }}"
155+
loop: "{{ os_manila_mount_shares }}"
156+
loop_control:
157+
label: "{{ item.share_name }}"
158+
159+
- name: Write Ceph client keyring
160+
ansible.builtin.template:
161+
src: ceph.keyring.j2
162+
dest: "{{ os_manila_mount_ceph_conf_path }}/ceph.client.{{ item.share_user }}.keyring"
163+
mode: "0600"
164+
owner: root
165+
group: root
166+
loop: "{{ os_manila_mount_share_info }}"
167+
loop_control:
168+
label: "{{ item.share_name }}"
169+
170+
- name: Mount the Ceph share
171+
ansible.posix.mount:
172+
path: "{{ item[0].mount_path }}"
173+
src: "{{ item[1].host }}:{{ item[1].export }}"
174+
fstype: ceph
175+
opts: "name={{ item[1].share_user }},{{ (item[0].mount_opts | default(os_manila_mount_opts)) | join(',') }}"
176+
# NB share_user is looked up here in case of autodetection
177+
state: "{{ item[0].mount_state | default(os_manila_mount_state) }}"
178+
loop: "{{ os_manila_mount_shares | zip(os_manila_mount_share_info) }}"
179+
loop_control:
180+
label: "{{ item[0].share_name }}"
181+
182+
- name: Ensure mounted directory has correct permissions
183+
ansible.builtin.file:
184+
path: "{{ item.mount_path }}"
185+
state: directory
186+
owner: "{{ item.mount_user | default(omit) }}"
187+
group: "{{ item.mount_group | default(omit) }}"
188+
mode: "{{ item.mount_mode | default(omit) }}"
189+
loop: "{{ os_manila_mount_shares }}"
190+
loop_control:
191+
label: "{{ item.share_name }}"
192+
when: item.mount_state | default(os_manila_mount_state) in ['mounted' or 'ephemeral']
193+
when:
194+
- enable_manila
195+
- os_manila_mount_shares | length > 0
115196

116197
# TODO: - name: Basic users setup
117198

ansible/roles/compute_init/tasks/export.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,14 @@
3333
dest: /exports/cluster/hostvars/{{ inventory_hostname }}/hostvars.yml
3434
mode: u=rw,go=
3535
delegate_to: "{{ groups['control'] | first }}"
36+
37+
- name: Copy manila share info to /exports/cluster
38+
copy:
39+
content: "{{ os_manila_mount_share_info_var | to_nice_yaml }}"
40+
dest: /exports/cluster/manila_share_info.yml
41+
run_once: true
42+
delegate_to: "{{ groups['control'] | first }}"
43+
when: os_manila_mount_share_info is defined
44+
vars:
45+
os_manila_mount_share_info_var:
46+
os_manila_mount_share_info: "{{ os_manila_mount_share_info }}"

ansible/roles/compute_init/tasks/install.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
- name: Ensure directories exist
44
file:
5-
path: "/etc/ansible-init/{{ item }}"
5+
path: "/etc/ansible-init/playbooks/{{ item }}"
66
state: directory
77
owner: root
88
group: root
@@ -17,7 +17,7 @@
1717
- name: Inject files from roles
1818
copy:
1919
src: '{{ item.src }}'
20-
dest: '/etc/ansible-init/{{ item.dest }}'
20+
dest: '/etc/ansible-init/playbooks/{{ item.dest }}'
2121
owner: root
2222
group: root
2323
mode: 0644
@@ -30,10 +30,8 @@
3030
dest: templates/ceph.keyring.j2
3131
- src: ../../resolv_conf/files/NetworkManager-dns-none.conf
3232
dest: files/NetworkManager-dns-none.conf
33-
- src: ../../stackhpc.os-manila-mount/library/os_manila_share.py
34-
dest: library/os_manila_share.py
35-
- src: ../../basic_users/filter_plugins/filter_keys.py
36-
dest: filter_plugins/filter_keys.py
33+
# - src: ../../basic_users/filter_plugins/filter_keys.py
34+
# dest: filter_plugins/filter_keys.py
3735
- src: ../../stackhpc.nfs/tasks/nfs-clients.yml
3836
dest: tasks/nfs-clients.yml
3937

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
os_manila_mount_shares_arcus:
2+
- share_name: slurm-v2-home
3+
mount_path: /project
4+
5+
os_manila_mount_shares: "{{ os_manila_mount_shares_arcus if ci_cloud == 'ARCUS' else [] }}"

0 commit comments

Comments
 (0)