Skip to content

Commit c6c8c78

Browse files
authored
Fix CIS play skipping kolla user on non-Kolla hosts (#2011)
Signed-off-by: Bartosz Bezak <bartosz@stackhpc.com>
1 parent 4d167d2 commit c6c8c78

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

etc/kayobe/ansible/maintenance/cis.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,26 @@
2020
state: present
2121
when: ansible_facts.distribution == 'Ubuntu'
2222

23+
- name: Gather passwd entries
24+
ansible.builtin.getent:
25+
database: passwd
26+
become: true
27+
2328
- name: Ensure service accounts have no expiry options set
2429
# This is to workaround an issue where we set the expiry to 365 days on kayobe
2530
# service accounts in a previous iteration of the CIS benchmark hardening
2631
# defaults. This should restore the defaults and can eventually be removed.
27-
ansible.builtin.command: chage -m 0 -M 99999 -W 7 -I -1 {{ item }}
32+
ansible.builtin.user:
33+
name: "{{ item }}"
34+
password_expire_min: 0
35+
password_expire_max: 99999
36+
password_expire_warn: 7
37+
expires: -1
2838
become: true
29-
changed_when: false
30-
with_items:
39+
loop:
3140
- "{{ kayobe_ansible_user }}"
3241
- "{{ kolla_ansible_user }}"
42+
when: item in ansible_facts.getent_passwd
3343

3444
- name: Security hardening
3545
hosts: cis-hardening
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
CIS hardening playbook skips service accounts that do not exist on the host
5+
(e.g. kolla on non-Kolla/Ceph-only nodes) to avoid errors.

0 commit comments

Comments
 (0)