Skip to content

Commit 5552212

Browse files
committed
update ansible remediation
1 parent 0a1e4d0 commit 5552212

File tree

1 file changed

+25
-3
lines changed
  • linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/ansible

1 file changed

+25
-3
lines changed

linux_os/guide/system/accounts/accounts-physical/require_singleuser_auth/ansible/shared.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# disruption = low
66

77
{{% if 'rhel' not in product and product != 'fedora' %}}
8-
- name: Require single user mode password
8+
- name: "{{{ rule_title }}} - Require single user mode password"
99
lineinfile:
1010
create: yes
1111
dest: /usr/lib/systemd/system/rescue.service
@@ -16,10 +16,32 @@
1616
line: 'ExecStart=-/bin/sh -c "/sbin/sulogin; /usr/bin/systemctl --fail --no-block default"'
1717
{{%- endif %}}
1818
{{% else %}}
19+
- name: "{{{ rule_title }}} - find files which already override Execstart of rescue.service"
20+
ansible.builtin.find:
21+
paths: "/etc/systemd/system/rescue.service.d"
22+
patterns: "*.conf"
23+
contains: '^\s*ExecStart=.*$'
24+
register: rescue_service_overrides_found
25+
26+
- name: "{{{ rule_title }}} - set files containing ExecStart overrides as target"
27+
ansible.builtin.set_fact:
28+
rescue_service_remediation_target_file: "{{ rescue_service_overrides_found.files | map(attribute='path') | list }}"
29+
when: rescue_service_overrides_found.matched is defined and rescue_service_overrides_found.matched > 0
30+
31+
- name: "{{{ rule_title }}} - set default target for rescue.service override"
32+
ansible.builtin.set_fact:
33+
rescue_service_remediation_target_file:
34+
- "/etc/systemd/system/rescue.service.d/10-oscap.conf"
35+
when: rescue_service_overrides_found.matched is defined and rescue_service_overrides_found.matched == 0
36+
1937
- name: "{{{ rule_title }}} - Require emergency user mode password"
2038
community.general.ini_file:
21-
path: "/etc/systemd/system/rescue.service.d/10-oscap.conf"
39+
path: "{{ item }}"
2240
section: "Service"
2341
option: "ExecStart"
24-
value: "-/usr/lib/systemd/systemd-sulogin-shell rescue"
42+
values:
43+
- ""
44+
- "-/usr/lib/systemd/systemd-sulogin-shell rescue"
45+
loop: "{{ rescue_service_remediation_target_file }}"
46+
2547
{{% endif %}}

0 commit comments

Comments
 (0)