Skip to content

Commit f7bc9c6

Browse files
Arden97claude
andcommitted
add default domains to sssd rules
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 38070ca commit f7bc9c6

15 files changed

Lines changed: 176 additions & 128 deletions

File tree

linux_os/guide/services/sssd/sssd_certificate_verification/ansible/shared.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,29 @@
55
# disruption = medium
66
{{{ ansible_instantiate_variables("var_sssd_certificate_verification_digest_function") }}}
77

8-
- name: Ensure that "certificate_verification" is not set in /etc/sssd/sssd.conf
8+
{{% set sssd_conf = "/etc/sssd/sssd.conf" -%}}
9+
{{% set sssd_conf_dir = "/etc/sssd/conf.d" -%}}
10+
{{{ ansible_sssd_ensure_default_domain(sssd_conf, sssd_conf_dir) }}}
11+
12+
- name: Ensure that "certificate_verification" is not set in {{{ sssd_conf }}}
913
community.general.ini_file:
10-
path: /etc/sssd/sssd.conf
14+
path: {{{ sssd_conf }}}
1115
section: sssd
1216
option: certificate_verification
1317
state: absent
1418
mode: 0600
1519

16-
- name: 'Ensure that "certificate_verification" is not set in /etc/sssd/conf.d/*.conf'
20+
- name: 'Ensure that "certificate_verification" is not set in {{{ sssd_conf_dir }}}/*.conf'
1721
community.general.ini_file:
18-
path: /etc/sssd/conf.d/*.conf
22+
path: {{{ sssd_conf_dir }}}/*.conf
1923
section: sssd
2024
option: certificate_verification
2125
state: absent
2226
mode: 0600
2327

2428
- name: Ensure that "certificate_verification" is set
2529
community.general.ini_file:
26-
path: /etc/sssd/conf.d/certificate_verification.conf
30+
path: {{{ sssd_conf_dir }}}/certificate_verification.conf
2731
section: sssd
2832
option: certificate_verification
2933
value: "ocsp_dgst={{ var_sssd_certificate_verification_digest_function }}"

linux_os/guide/services/sssd/sssd_certificate_verification/bash/shared.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
OLD_UMASK=$(umask)
1212
umask u=rw,go=
1313

14-
MAIN_CONF="/etc/sssd/conf.d/certificate_verification.conf"
14+
SSSD_CONF="/etc/sssd/sssd.conf"
15+
SSSD_CONF_DIR="/etc/sssd/conf.d"
16+
{{{ bash_sssd_ensure_default_domain("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
1517

16-
{{{ bash_ensure_ini_config("$MAIN_CONF /etc/sssd/sssd.conf /etc/sssd/conf.d/*.conf", "sssd", "certificate_verification", "ocsp_dgst=$var_sssd_certificate_verification_digest_function") }}}
18+
MAIN_CONF="$SSSD_CONF_DIR/certificate_verification.conf"
19+
20+
{{{ bash_ensure_ini_config("$MAIN_CONF $SSSD_CONF $SSSD_CONF_DIR/*.conf", "sssd", "certificate_verification", "ocsp_dgst=$var_sssd_certificate_verification_digest_function") }}}
1721

1822
umask $OLD_UMASK

linux_os/guide/services/sssd/sssd_enable_pam_services/ansible/shared.yml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@
44
# complexity = low
55
# disruption = medium
66

7-
- name: {{{ rule_title }}} - Find all the conf files inside the /etc/sssd/conf.d/ directory
7+
{{% set sssd_conf = "/etc/sssd/sssd.conf" -%}}
8+
{{% set sssd_conf_dir = "/etc/sssd/conf.d" -%}}
9+
{{{ ansible_sssd_ensure_default_domain(sssd_conf, sssd_conf_dir) }}}
10+
11+
- name: {{{ rule_title }}} - Find all the conf files inside the {{{ sssd_conf_dir }}} directory
812
ansible.builtin.find:
913
paths:
10-
- "/etc/sssd/conf.d/"
14+
- "{{{ sssd_conf_dir }}}"
1115
patterns: "*.conf"
1216
register: sssd_conf_d_files
1317

14-
- name: {{{ rule_title }}} - Modify lines in files in the /etc/sssd/conf.d/ directory
18+
- name: {{{ rule_title }}} - Modify lines in files in the {{{ sssd_conf_dir }}} directory
1519
ansible.builtin.replace:
1620
path: "{{ item }}"
1721
regexp: '^(\s*\[sssd\].*(?:\n\s*[^[\s].*)*\n\s*services\s*=(?!.*\bpam\b).*)$'
@@ -20,32 +24,32 @@
2024
register: modify_lines_sssd_conf_d_files
2125
when: sssd_conf_d_files.matched is defined and sssd_conf_d_files.matched >= 1
2226

23-
- name: {{{ rule_title }}} - Find /etc/sssd/sssd.conf
27+
- name: {{{ rule_title }}} - Find {{{ sssd_conf }}}
2428
ansible.builtin.stat:
25-
path: /etc/sssd/sssd.conf
29+
path: {{{ sssd_conf }}}
2630
register: sssd_conf_file
2731

28-
- name: {{{ rule_title }}} - Modify lines in /etc/sssd/sssd.conf
32+
- name: {{{ rule_title }}} - Modify lines in {{{ sssd_conf }}}
2933
ansible.builtin.replace:
30-
path: "/etc/sssd/sssd.conf"
34+
path: "{{{ sssd_conf }}}"
3135
regexp: '^(\s*\[sssd\].*(?:\n\s*[^[\s].*)*\n\s*services\s*=(?!.*\bpam\b).*)$'
3236
replace: '\1,pam'
3337
register: modify_lines_sssd_conf_file
3438
when: sssd_conf_file.stat.exists
3539

36-
- name: {{{ rule_title }}} - Find services key in /etc/sssd/sssd.conf
40+
- name: {{{ rule_title }}} - Find services key in {{{ sssd_conf }}}
3741
ansible.builtin.replace:
38-
path: "/etc/sssd/sssd.conf"
42+
path: "{{{ sssd_conf }}}"
3943
regexp: '^\s*\[sssd\][^\[\]]*?(?:\n(?!\[)[^\n]*?services\s*=)+'
4044
replace: ''
4145
changed_when: false
4246
check_mode: true
4347
register: sssd_conf_file_services
4448
when: sssd_conf_file.stat.exists
4549

46-
- name: {{{ rule_title }}} - Insert entry to /etc/sssd/sssd.conf
50+
- name: {{{ rule_title }}} - Insert entry to {{{ sssd_conf }}}
4751
community.general.ini_file:
48-
path: /etc/sssd/sssd.conf
52+
path: {{{ sssd_conf }}}
4953
section: sssd
5054
option: services
5155
value: pam

linux_os/guide/services/sssd/sssd_enable_pam_services/bash/shared.sh

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,13 @@ OLD_UMASK=$(umask)
88
umask u=rw,go=
99

1010
SSSD_CONF="/etc/sssd/sssd.conf"
11-
SSSD_CONF_DIR="/etc/sssd/conf.d/*.conf"
11+
SSSD_CONF_DIR="/etc/sssd/conf.d"
12+
{{{ bash_sssd_ensure_default_domain("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
1213

13-
if [ ! -f "$SSSD_CONF" ] && [ ! -f "$SSSD_CONF_DIR" ]; then
14-
mkdir -p /etc/sssd
15-
touch "$SSSD_CONF"
16-
fi
1714

1815
# Flag to check if there is already services with pam
1916
service_already_exist=false
20-
for f in $SSSD_CONF $SSSD_CONF_DIR; do
17+
for f in $SSSD_CONF $SSSD_CONF_DIR/*.conf; do
2118
if [ ! -e "$f" ]; then
2219
continue
2320
fi
@@ -39,7 +36,7 @@ done
3936

4037
# If there was no service in [sssd], add it to first config
4138
if [ "$service_already_exist" = false ]; then
42-
for f in $SSSD_CONF $SSSD_CONF_DIR; do
39+
for f in $SSSD_CONF $SSSD_CONF_DIR/*.conf; do
4340
cat << EOF >> "$f"
4441
[sssd]
4542
services = pam

linux_os/guide/services/sssd/sssd_enable_smartcards/ansible/shared.yml

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,26 @@
33
# strategy = configure
44
# complexity = low
55
# disruption = medium
6-
- name: "Test for domain group"
7-
ansible.builtin.command: grep '^\s*\[domain\/[^]]*]' /etc/sssd/sssd.conf
8-
register: test_grep_domain
9-
failed_when: false
10-
changed_when: False
11-
check_mode: no
12-
13-
- name: "Add default domain group (if no domain there)"
14-
community.general.ini_file:
15-
path: /etc/sssd/sssd.conf
16-
section: "{{ item.section }}"
17-
option: "{{ item.option }}"
18-
value: "{{ item.value }}"
19-
create: yes
20-
mode: 0600
21-
with_items:
22-
- { section: sssd, option: domains, value: default}
23-
- { section: domain/default, option: id_provider, value: files }
24-
when:
25-
- test_grep_domain.stdout is defined
26-
- test_grep_domain.stdout | length < 1
6+
{{% set sssd_conf = "/etc/sssd/sssd.conf" -%}}
7+
{{% set sssd_conf_dir = "/etc/sssd/conf.d" -%}}
8+
{{{ ansible_sssd_ensure_default_domain(sssd_conf, sssd_conf_dir) }}}
279

2810
- name: "Enable Smartcards in SSSD"
2911
community.general.ini_file:
30-
dest: /etc/sssd/sssd.conf
12+
dest: {{{ sssd_conf }}}
3113
section: pam
3214
option: pam_cert_auth
3315
value: 'True'
3416
create: yes
3517
mode: 0600
3618

37-
- name: Find all the conf files inside /etc/sssd/conf.d/
19+
- name: Find all the conf files inside {{{ sssd_conf_dir }}}
3820
ansible.builtin.find:
39-
paths: "/etc/sssd/conf.d/"
21+
paths: "{{{ sssd_conf_dir }}}"
4022
patterns: "*.conf"
4123
register: sssd_conf_d_files
4224

43-
- name: Fix pam_cert_auth configuration in /etc/sssd/conf.d/
25+
- name: Fix pam_cert_auth configuration in {{{ sssd_conf_dir }}}
4426
ansible.builtin.replace:
4527
path: "{{ item.path }}"
4628
regexp: '[^#]*pam_cert_auth.*'

linux_os/guide/services/sssd/sssd_enable_smartcards/bash/shared.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
OLD_UMASK=$(umask)
1010
umask u=rw,go=
1111

12-
{{{ bash_ensure_ini_config("/etc/sssd/sssd.conf /etc/sssd/conf.d/*.conf", "pam", "pam_cert_auth", "True") }}}
12+
SSSD_CONF="/etc/sssd/sssd.conf"
13+
SSSD_CONF_DIR="/etc/sssd/conf.d"
14+
{{{ bash_sssd_ensure_default_domain("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
15+
16+
{{{ bash_ensure_ini_config("$SSSD_CONF $SSSD_CONF_DIR/*.conf", "pam", "pam_cert_auth", "True") }}}
1317

1418
umask $OLD_UMASK
1519

linux_os/guide/services/sssd/sssd_memcache_timeout/ansible/shared.yml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,13 @@
55
# disruption = medium
66
{{{ ansible_instantiate_variables("var_sssd_memcache_timeout") }}}
77

8-
- name: "Test for domain group"
9-
ansible.builtin.command: grep '\s*\[domain\/[^]]*]' /etc/sssd/sssd.conf
10-
register: test_grep_domain
11-
failed_when: false
12-
changed_when: False
13-
check_mode: no
14-
15-
- name: "Add default domain group (if no domain there)"
16-
community.general.ini_file:
17-
path: /etc/sssd/sssd.conf
18-
section: "{{ item.section }}"
19-
option: "{{ item.option }}"
20-
value: "{{ item.value }}"
21-
create: yes
22-
mode: 0600
23-
with_items:
24-
- { section: sssd, option: domains, value: default}
25-
- { section: domain/default, option: id_provider, value: files }
26-
when:
27-
- test_grep_domain.stdout is defined
28-
- test_grep_domain.stdout | length < 1
8+
{{% set sssd_conf = "/etc/sssd/sssd.conf" -%}}
9+
{{% set sssd_conf_dir = "/etc/sssd/conf.d" -%}}
10+
{{{ ansible_sssd_ensure_default_domain(sssd_conf, sssd_conf_dir) }}}
2911

3012
- name: "Configure SSSD's Memory Cache to Expire"
3113
community.general.ini_file:
32-
dest: /etc/sssd/sssd.conf
14+
dest: {{{ sssd_conf }}}
3315
section: nss
3416
option: memcache_timeout
3517
value: "{{ var_sssd_memcache_timeout }}"

linux_os/guide/services/sssd/sssd_memcache_timeout/bash/shared.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
OLD_UMASK=$(umask)
88
umask u=rw,go=
99

10-
{{{ bash_ensure_ini_config("/etc/sssd/sssd.conf", "nss", "memcache_timeout", "$var_sssd_memcache_timeout") }}}
10+
SSSD_CONF="/etc/sssd/sssd.conf"
11+
SSSD_CONF_DIR="/etc/sssd/conf.d"
12+
{{{ bash_sssd_ensure_default_domain("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
13+
14+
{{{ bash_ensure_ini_config("$SSSD_CONF", "nss", "memcache_timeout", "$var_sssd_memcache_timeout") }}}
1115

1216
umask $OLD_UMASK

linux_os/guide/services/sssd/sssd_offline_cred_expiration/ansible/shared.yml

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,26 @@
33
# strategy = configure
44
# complexity = low
55
# disruption = medium
6-
- name: "Test for domain group"
7-
ansible.builtin.command: grep '\s*\[domain\/[^]]*]' /etc/sssd/sssd.conf
8-
register: test_grep_domain
9-
failed_when: false
10-
changed_when: False
11-
check_mode: no
12-
13-
- name: "Add default domain group (if no domain there)"
14-
community.general.ini_file:
15-
path: /etc/sssd/sssd.conf
16-
section: "{{ item.section }}"
17-
option: "{{ item.option }}"
18-
value: "{{ item.value }}"
19-
create: yes
20-
mode: 0600
21-
with_items:
22-
- { section: sssd, option: domains, value: default}
23-
- { section: domain/default, option: id_provider, value: files }
24-
when:
25-
- test_grep_domain.stdout is defined
26-
- test_grep_domain.stdout | length < 1
6+
{{% set sssd_conf = "/etc/sssd/sssd.conf" -%}}
7+
{{% set sssd_conf_dir = "/etc/sssd/conf.d" -%}}
8+
{{{ ansible_sssd_ensure_default_domain(sssd_conf, sssd_conf_dir) }}}
279

2810
- name: "Configure SSD to Expire Offline Credentials"
2911
community.general.ini_file:
30-
dest: /etc/sssd/sssd.conf
12+
dest: {{{ sssd_conf }}}
3113
section: pam
3214
option: offline_credentials_expiration
3315
value: 1
3416
create: yes
3517
mode: 0600
3618

37-
- name: Find all the conf files inside /etc/sssd/conf.d/
19+
- name: Find all the conf files inside {{{ sssd_conf_dir }}}
3820
ansible.builtin.find:
39-
paths: "/etc/sssd/conf.d/"
21+
paths: "{{{ sssd_conf_dir }}}"
4022
patterns: "*.conf"
4123
register: sssd_conf_d_files
4224

43-
- name: Fix offline_credentials_expiration configuration in /etc/sssd/conf.d/
25+
- name: Fix offline_credentials_expiration configuration in {{{ sssd_conf_dir }}}
4426
ansible.builtin.replace:
4527
path: "{{ item.path }}"
4628
regexp: '[^#]*offline_credentials_expiration.*'

linux_os/guide/services/sssd/sssd_offline_cred_expiration/bash/shared.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
OLD_UMASK=$(umask)
1010
umask u=rw,go=
1111

12-
{{{ bash_ensure_ini_config("/etc/sssd/sssd.conf /etc/sssd/conf.d/*.conf", "pam", "offline_credentials_expiration", "1") }}}
12+
SSSD_CONF="/etc/sssd/sssd.conf"
13+
SSSD_CONF_DIR="/etc/sssd/conf.d"
14+
{{{ bash_sssd_ensure_default_domain("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
15+
16+
{{{ bash_ensure_ini_config("$SSSD_CONF $SSSD_CONF_DIR/*.conf", "pam", "offline_credentials_expiration", "1") }}}
1317

1418
umask $OLD_UMASK

0 commit comments

Comments
 (0)