Skip to content

Commit 5aaf906

Browse files
committed
use ansible-init user for cluster share
1 parent 971728b commit 5aaf906

File tree

8 files changed

+54
-44
lines changed

8 files changed

+54
-44
lines changed

ansible/roles/cacerts/tasks/export.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
ansible.builtin.copy:
44
src: "{{ item }}"
55
dest: /exports/cluster/cacerts/
6-
owner: slurm
7-
group: root
8-
mode: "0644"
6+
owner: ansible-init
7+
group: ansible-init
8+
mode: u=rw,go=
99
with_fileglob:
1010
- "{{ cacerts_cert_dir }}/*"
1111
delegate_to: "{{ groups['control'] | first }}"

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
- ansible.builtin.meta: end_play
8484
- name: Check if hostvars exist
8585
become: true
86-
become_user: slurm
86+
become_user: ansible-init # share is root-squashed
8787
ansible.builtin.stat:
8888
path: "/mnt/cluster/hostvars/{{ ansible_hostname }}/hostvars.yml"
8989
register: hostvars_stat
@@ -98,7 +98,7 @@
9898
- ansible.builtin.meta: end_play
9999
- name: Sync /mnt/cluster to /var/tmp
100100
become: true
101-
become_user: slurm
101+
become_user: ansible-init # share is root-squashed
102102
ansible.posix.synchronize:
103103
src: "/mnt/cluster/"
104104
dest: "/var/tmp/cluster/"

ansible/roles/compute_init/tasks/export.yml

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,74 @@
11
---
2-
- name: Ensure the /exports/cluster directory exists
2+
- name: Ensure /exports/cluster directory structure exists
33
ansible.builtin.file:
44
path: /exports/cluster
55
state: directory
6-
owner: slurm
7-
group: root
6+
owner: ansible-init
7+
group: ansible-init
88
mode: u=rX,g=rwX,o=
99
run_once: true
10+
loop:
11+
- /exports/cluster
12+
- /exports/cluster/hostvars
13+
- /exports/cluster/cacerts
14+
- /exports/cluster/cvmfs
15+
- /exports/cluster/hostconfig
16+
1017
delegate_to: "{{ groups['control'] | first }}"
1118

1219
- name: Copy /etc/hosts to /exports/cluster
1320
ansible.builtin.copy:
1421
src: /etc/hosts
1522
dest: /exports/cluster/hosts
16-
owner: slurm
17-
group: root
18-
mode: u=r,g=rw,o=
23+
owner: ansible-init
24+
group: ansible-init
25+
mode: u=rw,go=r
1926
remote_src: true
2027
run_once: true
2128
delegate_to: "{{ groups['control'] | first }}"
2229

23-
- name: Create hostvars directory
30+
- name: Create per-host hostvars directory
2431
ansible.builtin.file:
2532
path: /exports/cluster/hostvars/{{ inventory_hostname }}/
2633
state: directory
27-
owner: slurm
28-
group: root
29-
mode: u=rX,g=rwX,o=
34+
owner: ansible-init
35+
group: ansible-init
36+
mode: u=rwX,go=
3037
delegate_to: "{{ groups['control'] | first }}"
3138

3239
- name: Template out hostvars
3340
ansible.builtin.template:
3441
src: hostvars.yml.j2
3542
dest: /exports/cluster/hostvars/{{ inventory_hostname }}/hostvars.yml
36-
owner: slurm
37-
group: root
38-
mode: u=r,g=rw,o=
43+
owner: ansible-init
44+
group: ansible-init
45+
mode: u=rw,go=
3946
delegate_to: "{{ groups['control'] | first }}"
4047

41-
- name: Copy manila share info to /exports/cluster
42-
ansible.builtin.copy:
43-
content: "{{ os_manila_mount_share_info_var | to_nice_yaml }}"
48+
- name: Template manila share info to /exports/cluster
49+
ansible.builtin.template:
50+
src: os_manila_mount_share_info.j2
4451
dest: /exports/cluster/manila_share_info.yml
45-
owner: slurm
46-
group: root
47-
mode: u=r,g=rw,o=
52+
owner: ansible-init
53+
group: ansible-init
54+
mode: u=rw,go=
4855
run_once: true
4956
delegate_to: "{{ groups['control'] | first }}"
5057
when: os_manila_mount_share_info is defined
51-
vars:
52-
os_manila_mount_share_info_var:
53-
os_manila_mount_share_info: "{{ os_manila_mount_share_info }}"
54-
55-
- name: Ensure /exports/cluster/cvmfs directory exists
56-
ansible.builtin.file:
57-
path: /exports/cluster/cvmfs
58-
state: directory
59-
owner: slurm
60-
group: root
61-
mode: "0755"
62-
run_once: true
63-
delegate_to: "{{ groups['control'] | first }}"
6458

6559
- name: Export cacerts
6660
ansible.builtin.include_role:
6761
name: cacerts
6862
tasks_from: export.yml
6963
when: "'cacerts' in group_names"
7064

71-
- name: Create hostconfig directory
65+
- name: Create per-host hostconfig directory
7266
ansible.builtin.file:
7367
path: "/exports/cluster/hostconfig/{{ inventory_hostname }}/"
7468
state: directory
75-
owner: slurm
76-
group: root
77-
mode: u=rX,g=rwX,o=
69+
owner: ansible-init
70+
group: ansible-init
71+
mode: u=rwX,go=
7872
delegate_to: "{{ groups['control'] | first }}"
7973

8074
- name: Template sssd config
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ os_manila_mount_share_info_var | to_nice_yaml }}

ansible/roles/nhc/tasks/export.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
ansible.builtin.template:
44
src: "{{ nhc_config_template }}"
55
dest: "/exports/cluster/hostconfig/{{ inventory_hostname }}/nhc.conf"
6-
mode: "0644"
6+
owner: ansible-init
7+
group: ansible-init
8+
mode: u=rw,go=
79
delegate_to: "{{ groups['control'] | first }}"

ansible/roles/sssd/tasks/export.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ansible.builtin.template:
55
src: "{{ sssd_conf_src }}"
66
dest: "/exports/cluster/hostconfig/{{ inventory_hostname }}/sssd.conf"
7-
owner: root
8-
group: root
7+
owner: ansible-init
8+
group: ansible-init
99
mode: u=rw,go=
1010
delegate_to: "{{ groups['control'] | first }}"

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ appliances_local_users_default:
7777
shell: /sbin/nologin
7878
system: true
7979
enable: "{{ 'grafana' in group_names }}"
80+
81+
- group:
82+
name: ansible-init
83+
gid: 301
84+
user:
85+
name: ansible-init
86+
comment: ansible-init user
87+
uid: 301
88+
create_home: false
89+
shell: /sbin/nologin
90+
system: true
91+
enable: "{{ 'ansible_init' in group_names }}"
8092

8193
# Overide this to add extra users whilst keeping the defaults.
8294
appliances_local_users_extra: [] # see format of appliances_local_users_default above

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ nfs_configuration_compute_nodes: # cluster configuration for compute_init/slurm-
3131
server: "{{ inventory_hostname in groups['control'] }}"
3232
clients: false
3333
nfs_export: "/exports/cluster"
34+
nfs_export_options: "ro,secure,root_squash"
3435

3536
nfs_configurations_extra: [] # site-specific nfs shares
3637

0 commit comments

Comments
 (0)