Skip to content

Commit a6d580a

Browse files
committed
fix task guarding, improve compute-init script
1 parent 4f76609 commit a6d580a

File tree

6 files changed

+19
-94
lines changed

6 files changed

+19
-94
lines changed

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

Lines changed: 10 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -143,90 +143,18 @@
143143
when: enable_etc_hosts
144144

145145
- name: Configure sssd
146-
block:
147-
- name: Manage sssd.conf configuration
148-
copy:
149-
src: "/mnt/cluster/hostconfig/{{ ansible_hostname }}/sssd.conf"
150-
dest: "{{ sssd_conf_dest }}"
151-
owner: root
152-
group: root
153-
mode: "0600"
154-
155-
- name: Restart sssd
156-
systemd:
157-
name: sssd
158-
state: restarted
159-
when: sssd_started | bool
160-
161-
- name: Ensure sssd service state
162-
systemd:
163-
name: sssd
164-
state: "{{ 'started' if sssd_started | bool else 'stopped' }}"
165-
enabled: "{{ sssd_enabled | bool }}"
166-
167-
- name: Get current authselect configuration
168-
command: authselect current --raw
169-
changed_when: false
170-
failed_when:
171-
- _authselect_current.rc != 0
172-
- "'No existing configuration detected' not in _authselect_current.stdout"
173-
register: _authselect_current # stdout: sssd with-mkhomedir
174-
175-
- name: Configure nsswitch and PAM for SSSD
176-
command: "authselect select sssd --force{% if sssd_enable_mkhomedir | bool %} with-mkhomedir{% endif %}"
177-
when: "'sssd' not in _authselect_current.stdout"
178-
179-
- name: "Ensure oddjob is started"
180-
service:
181-
name: oddjobd
182-
state: 'started'
183-
enabled: true
184-
when: sssd_enable_mkhomedir | bool
185-
when: enable_sssd
146+
ansible.builtin.include_role:
147+
name: sssd
148+
tasks_from: configure.yml
149+
vars:
150+
sssd_conf_src: "/mnt/cluster/hostconfig/{{ ansible_hostname }}/sssd.conf"
151+
when: enable_sshd
186152

187153
- name: Configure sshd
188-
block:
189-
- name: Grab facts to determine distribution
190-
setup:
191-
192-
- name: Ensure drop in directory exists
193-
file:
194-
path: /etc/ssh/sshd_config.d/*.conf
195-
state: directory
196-
owner: root
197-
group: root
198-
mode: "0700"
199-
200-
- name: Ensure drop in directory is included
201-
blockinfile:
202-
dest: /etc/ssh/sshd_config
203-
content: |
204-
# To modify the system-wide sshd configuration, create a *.conf file under
205-
# /etc/ssh/sshd_config.d/ which will be automatically included below
206-
Include /etc/ssh/sshd_config.d/*.conf
207-
state: present
208-
insertafter: "# default value."
209-
validate: sshd -t -f %s
210-
when: ansible_facts.distribution_major_version == '8'
211-
212-
- name: Restart sshd
213-
systemd:
214-
name: sshd
215-
state: restarted
216-
217-
- name: Manage sshd.conf configuration
218-
copy:
219-
src: "/mnt/cluster/hostconfig/{{ ansible_hostname }}/sshd.conf"
220-
dest: "{{ sshd_conf_dest }}"
221-
owner: root
222-
group: root
223-
mode: "0600"
224-
validate: sshd -t -f %s
225-
226-
- name: Restart sshd
227-
systemd:
228-
name: sshd
229-
state: restarted
154+
ansible.builtin.include_role:
155+
name: sshd
156+
vars:
157+
sshd_conf_src: "/mnt/cluster/hostconfig/{{ ansible_hostname }}/sshd.conf"
230158
when: enable_sshd
231159

232160
- name: Configure tuned

ansible/roles/compute_init/tasks/export.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@
8585
import_role:
8686
name: sssd
8787
tasks_from: export.yml
88+
when: "'sssd' in group_names"
8889

8990
- name: Template sshd config
9091
import_role:
9192
name: sshd
9293
tasks_from: export.yml
94+
when: "'sshd' in group_names"

ansible/roles/compute_init/tasks/install.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- library
1414
- filter_plugins
1515
- tasks
16+
- roles
1617

1718
- name: Inject files from roles
1819
copy:
@@ -32,6 +33,10 @@
3233
dest: files/NetworkManager-dns-none.conf
3334
- src: ../../basic_users/filter_plugins/filter_keys.py
3435
dest: filter_plugins/filter_keys.py
36+
- src: ../../sssd
37+
dest: roles/
38+
- src: ../../sshd
39+
dest: roles/
3540
- src: ../../tuned/tasks/configure.yml
3641
dest: tasks/tuned.yml
3742
- src: ../../stackhpc.nfs/tasks/nfs-clients.yml

ansible/roles/sshd/tasks/export.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# Exclusively used for compute-init
22
- name: Inject host specific config template
33
template:
4-
src: "{{ sshd_conf_src | default('') }}"
4+
src: "{{ sshd_conf_src }}"
55
dest: "/exports/cluster/hostconfig/{{ inventory_hostname }}/sshd.conf"
66
owner: root
77
group: root
88
mode: u=rw,go=
9-
when:
10-
- sshd_conf_src != ''
119
delegate_to: "{{ groups['control'] | first }}"

ansible/roles/sssd/tasks/configure.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@
2727
command: "authselect select sssd --force{% if sssd_enable_mkhomedir | bool %} with-mkhomedir{% endif %}"
2828
when: "'sssd' not in _authselect_current.stdout"
2929

30-
- name: "Ensure oddjob is started"
31-
service:
32-
name: oddjobd
33-
state: "{{ 'started' if sssd_enable_mkhomedir else 'stopped' }}"
34-
enabled: "{{ sssd_enable_mkhomedir }}"
35-
3630
- name: "Ensure oddjob is started"
3731
service:
3832
name: oddjobd

ansible/roles/sssd/tasks/export.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# Exclusively used for compute-init
22
- name: Inject host specific config template
33
template:
4-
src: "{{ sssd_conf_src | default('') }}"
4+
src: "{{ sssd_conf_src }}"
55
dest: "/exports/cluster/hostconfig/{{ inventory_hostname }}/sssd.conf"
66
owner: root
77
group: root
88
mode: u=rw,go=
9-
when:
10-
- sssd_conf_src != ''
119
delegate_to: "{{ groups['control'] | first }}"

0 commit comments

Comments
 (0)