Skip to content

Commit ce09e45

Browse files
committed
add default domains to sssd rules
1 parent 38070ca commit ce09e45

15 files changed

Lines changed: 240 additions & 131 deletions

File tree

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

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,36 @@
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_config(sssd_conf, sssd_conf_dir, rule_title) }}}
11+
12+
{{% if product in ["fedora"] or (('rhel' in product or 'ol' in families) and product not in ['ol7', 'ol8', 'ol9', 'rhel8', 'rhel9']) %}}
13+
- name: "{{{ rule_title }}} - Install sssd-proxy for default domain"
14+
ansible.builtin.package:
15+
name: sssd-proxy
16+
state: present
17+
{{% endif %}}
18+
19+
- name: Ensure that "certificate_verification" is not set in {{{ sssd_conf }}}
920
community.general.ini_file:
10-
path: /etc/sssd/sssd.conf
21+
path: {{{ sssd_conf }}}
1122
section: sssd
1223
option: certificate_verification
1324
state: absent
1425
mode: 0600
1526

16-
- name: 'Ensure that "certificate_verification" is not set in /etc/sssd/conf.d/*.conf'
27+
- name: 'Ensure that "certificate_verification" is not set in {{{ sssd_conf_dir }}}/*.conf'
1728
community.general.ini_file:
18-
path: /etc/sssd/conf.d/*.conf
29+
path: {{{ sssd_conf_dir }}}/*.conf
1930
section: sssd
2031
option: certificate_verification
2132
state: absent
2233
mode: 0600
2334

2435
- name: Ensure that "certificate_verification" is set
2536
community.general.ini_file:
26-
path: /etc/sssd/conf.d/certificate_verification.conf
37+
path: {{{ sssd_conf_dir }}}/certificate_verification.conf
2738
section: sssd
2839
option: certificate_verification
2940
value: "ocsp_dgst={{ var_sssd_certificate_verification_digest_function }}"

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@
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_config("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
17+
{{% if product in ["fedora"] or (('rhel' in product or 'ol' in families) and product not in ['ol7', 'ol8', 'ol9', 'rhel8', 'rhel9']) %}}
18+
{{{ bash_package_install("sssd-proxy") }}}
19+
{{% endif %}}
1520
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") }}}
21+
MAIN_CONF="$SSSD_CONF_DIR/certificate_verification.conf"
22+
23+
{{{ bash_ensure_ini_config("$MAIN_CONF $SSSD_CONF $SSSD_CONF_DIR/*.conf", "sssd", "certificate_verification", "ocsp_dgst=$var_sssd_certificate_verification_digest_function") }}}
1724
1825
umask $OLD_UMASK

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

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@
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_config(sssd_conf, sssd_conf_dir, rule_title) }}}
10+
11+
{{% if product in ["fedora"] or (('rhel' in product or 'ol' in families) and product not in ['ol7', 'ol8', 'ol9', 'rhel8', 'rhel9']) %}}
12+
- name: "{{{ rule_title }}} - Install sssd-proxy for default domain"
13+
ansible.builtin.package:
14+
name: sssd-proxy
15+
state: present
16+
{{% endif %}}
17+
18+
- name: {{{ rule_title }}} - Find all the conf files inside the {{{ sssd_conf_dir }}} directory
819
ansible.builtin.find:
920
paths:
10-
- "/etc/sssd/conf.d/"
21+
- "{{{ sssd_conf_dir }}}"
1122
patterns: "*.conf"
1223
register: sssd_conf_d_files
1324

14-
- name: {{{ rule_title }}} - Modify lines in files in the /etc/sssd/conf.d/ directory
25+
- name: {{{ rule_title }}} - Modify lines in files in the {{{ sssd_conf_dir }}} directory
1526
ansible.builtin.replace:
1627
path: "{{ item }}"
1728
regexp: '^(\s*\[sssd\].*(?:\n\s*[^[\s].*)*\n\s*services\s*=(?!.*\bpam\b).*)$'
@@ -20,32 +31,32 @@
2031
register: modify_lines_sssd_conf_d_files
2132
when: sssd_conf_d_files.matched is defined and sssd_conf_d_files.matched >= 1
2233

23-
- name: {{{ rule_title }}} - Find /etc/sssd/sssd.conf
34+
- name: {{{ rule_title }}} - Find {{{ sssd_conf }}}
2435
ansible.builtin.stat:
25-
path: /etc/sssd/sssd.conf
36+
path: {{{ sssd_conf }}}
2637
register: sssd_conf_file
2738

28-
- name: {{{ rule_title }}} - Modify lines in /etc/sssd/sssd.conf
39+
- name: {{{ rule_title }}} - Modify lines in {{{ sssd_conf }}}
2940
ansible.builtin.replace:
30-
path: "/etc/sssd/sssd.conf"
41+
path: "{{{ sssd_conf }}}"
3142
regexp: '^(\s*\[sssd\].*(?:\n\s*[^[\s].*)*\n\s*services\s*=(?!.*\bpam\b).*)$'
3243
replace: '\1,pam'
3344
register: modify_lines_sssd_conf_file
3445
when: sssd_conf_file.stat.exists
3546

36-
- name: {{{ rule_title }}} - Find services key in /etc/sssd/sssd.conf
47+
- name: {{{ rule_title }}} - Find services key in {{{ sssd_conf }}}
3748
ansible.builtin.replace:
38-
path: "/etc/sssd/sssd.conf"
49+
path: "{{{ sssd_conf }}}"
3950
regexp: '^\s*\[sssd\][^\[\]]*?(?:\n(?!\[)[^\n]*?services\s*=)+'
4051
replace: ''
4152
changed_when: false
4253
check_mode: true
4354
register: sssd_conf_file_services
4455
when: sssd_conf_file.stat.exists
4556

46-
- name: {{{ rule_title }}} - Insert entry to /etc/sssd/sssd.conf
57+
- name: {{{ rule_title }}} - Insert entry to {{{ sssd_conf }}}
4758
community.general.ini_file:
48-
path: /etc/sssd/sssd.conf
59+
path: {{{ sssd_conf }}}
4960
section: sssd
5061
option: services
5162
value: pam
Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
# platform = Red Hat Virtualization 4,multi_platform_rhel,multi_platform_ol,multi_platform_almalinux,multi_platform_ubuntu
22

33

4-
54
# sssd configuration files must be created with 600 permissions if they don't exist
65
# otherwise the sssd module fails to start
76
OLD_UMASK=$(umask)
87
umask u=rw,go=
98

109
SSSD_CONF="/etc/sssd/sssd.conf"
11-
SSSD_CONF_DIR="/etc/sssd/conf.d/*.conf"
12-
13-
if [ ! -f "$SSSD_CONF" ] && [ ! -f "$SSSD_CONF_DIR" ]; then
14-
mkdir -p /etc/sssd
15-
touch "$SSSD_CONF"
16-
fi
10+
SSSD_CONF_DIR="/etc/sssd/conf.d"
11+
{{{ bash_sssd_ensure_default_config("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
12+
{{% if product in ["fedora"] or (('rhel' in product or 'ol' in families) and product not in ['ol7', 'ol8', 'ol9', 'rhel8', 'rhel9']) %}}
13+
{{{ bash_package_install("sssd-proxy") }}}
14+
{{% endif %}}
1715
1816
# Flag to check if there is already services with pam
1917
service_already_exist=false
20-
for f in $SSSD_CONF $SSSD_CONF_DIR; do
18+
for f in $SSSD_CONF $SSSD_CONF_DIR/*.conf; do
2119
if [ ! -e "$f" ]; then
2220
continue
2321
fi
@@ -39,13 +37,7 @@ done
3937
4038
# If there was no service in [sssd], add it to first config
4139
if [ "$service_already_exist" = false ]; then
42-
for f in $SSSD_CONF $SSSD_CONF_DIR; do
43-
cat << EOF >> "$f"
44-
[sssd]
45-
services = pam
46-
EOF
47-
break
48-
done
40+
{{{ bash_ensure_ini_config("$SSSD_CONF $SSSD_CONF_DIR/*.conf", "sssd", "services", "pam") }}}
4941
fi
5042
5143
umask $OLD_UMASK

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

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,33 @@
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
6+
{{% set sssd_conf = "/etc/sssd/sssd.conf" -%}}
7+
{{% set sssd_conf_dir = "/etc/sssd/conf.d" -%}}
8+
{{{ ansible_sssd_ensure_default_config(sssd_conf, sssd_conf_dir, rule_title) }}}
129

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
10+
{{% if product in ["fedora"] or (('rhel' in product or 'ol' in families) and product not in ['ol7', 'ol8', 'ol9', 'rhel8', 'rhel9']) %}}
11+
- name: "{{{ rule_title }}} - Install sssd-proxy for default domain"
12+
ansible.builtin.package:
13+
name: sssd-proxy
14+
state: present
15+
{{% endif %}}
2716

2817
- name: "Enable Smartcards in SSSD"
2918
community.general.ini_file:
30-
dest: /etc/sssd/sssd.conf
19+
dest: {{{ sssd_conf }}}
3120
section: pam
3221
option: pam_cert_auth
3322
value: 'True'
3423
create: yes
3524
mode: 0600
3625

37-
- name: Find all the conf files inside /etc/sssd/conf.d/
26+
- name: Find all the conf files inside {{{ sssd_conf_dir }}}
3827
ansible.builtin.find:
39-
paths: "/etc/sssd/conf.d/"
28+
paths: "{{{ sssd_conf_dir }}}"
4029
patterns: "*.conf"
4130
register: sssd_conf_d_files
4231

43-
- name: Fix pam_cert_auth configuration in /etc/sssd/conf.d/
32+
- name: Fix pam_cert_auth configuration in {{{ sssd_conf_dir }}}
4433
ansible.builtin.replace:
4534
path: "{{ item.path }}"
4635
regexp: '[^#]*pam_cert_auth.*'

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
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_config("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
15+
{{% if product in ["fedora"] or (('rhel' in product or 'ol' in families) and product not in ['ol7', 'ol8', 'ol9', 'rhel8', 'rhel9']) %}}
16+
{{{ bash_package_install("sssd-proxy") }}}
17+
{{% endif %}}
18+
19+
{{{ bash_ensure_ini_config("$SSSD_CONF $SSSD_CONF_DIR/*.conf", "pam", "pam_cert_auth", "True") }}}
1320
1421
umask $OLD_UMASK
1522

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

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,20 @@
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
8+
{{% set sssd_conf = "/etc/sssd/sssd.conf" -%}}
9+
{{% set sssd_conf_dir = "/etc/sssd/conf.d" -%}}
10+
{{{ ansible_sssd_ensure_default_config(sssd_conf, sssd_conf_dir, rule_title) }}}
1411

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
12+
{{% if product in ["fedora"] or (('rhel' in product or 'ol' in families) and product not in ['ol7', 'ol8', 'ol9', 'rhel8', 'rhel9']) %}}
13+
- name: "{{{ rule_title }}} - Install sssd-proxy for default domain"
14+
ansible.builtin.package:
15+
name: sssd-proxy
16+
state: present
17+
{{% endif %}}
2918

3019
- name: "Configure SSSD's Memory Cache to Expire"
3120
community.general.ini_file:
32-
dest: /etc/sssd/sssd.conf
21+
dest: {{{ sssd_conf }}}
3322
section: nss
3423
option: memcache_timeout
3524
value: "{{ var_sssd_memcache_timeout }}"

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
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_config("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
13+
{{% if product in ["fedora"] or (('rhel' in product or 'ol' in families) and product not in ['ol7', 'ol8', 'ol9', 'rhel8', 'rhel9']) %}}
14+
{{{ bash_package_install("sssd-proxy") }}}
15+
{{% endif %}}
16+
17+
{{{ bash_ensure_ini_config("$SSSD_CONF", "nss", "memcache_timeout", "$var_sssd_memcache_timeout") }}}
1118
1219
umask $OLD_UMASK

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

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,33 @@
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
6+
{{% set sssd_conf = "/etc/sssd/sssd.conf" -%}}
7+
{{% set sssd_conf_dir = "/etc/sssd/conf.d" -%}}
8+
{{{ ansible_sssd_ensure_default_config(sssd_conf, sssd_conf_dir, rule_title) }}}
129

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
10+
{{% if product in ["fedora"] or (('rhel' in product or 'ol' in families) and product not in ['ol7', 'ol8', 'ol9', 'rhel8', 'rhel9']) %}}
11+
- name: "{{{ rule_title }}} - Install sssd-proxy for default domain"
12+
ansible.builtin.package:
13+
name: sssd-proxy
14+
state: present
15+
{{% endif %}}
2716

2817
- name: "Configure SSD to Expire Offline Credentials"
2918
community.general.ini_file:
30-
dest: /etc/sssd/sssd.conf
19+
dest: {{{ sssd_conf }}}
3120
section: pam
3221
option: offline_credentials_expiration
3322
value: 1
3423
create: yes
3524
mode: 0600
3625

37-
- name: Find all the conf files inside /etc/sssd/conf.d/
26+
- name: Find all the conf files inside {{{ sssd_conf_dir }}}
3827
ansible.builtin.find:
39-
paths: "/etc/sssd/conf.d/"
28+
paths: "{{{ sssd_conf_dir }}}"
4029
patterns: "*.conf"
4130
register: sssd_conf_d_files
4231

43-
- name: Fix offline_credentials_expiration configuration in /etc/sssd/conf.d/
32+
- name: Fix offline_credentials_expiration configuration in {{{ sssd_conf_dir }}}
4433
ansible.builtin.replace:
4534
path: "{{ item.path }}"
4635
regexp: '[^#]*offline_credentials_expiration.*'

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
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_config("$SSSD_CONF", "$SSSD_CONF_DIR") }}}
15+
{{% if product in ["fedora"] or (('rhel' in product or 'ol' in families) and product not in ['ol7', 'ol8', 'ol9', 'rhel8', 'rhel9']) %}}
16+
{{{ bash_package_install("sssd-proxy") }}}
17+
{{% endif %}}
18+
19+
{{{ bash_ensure_ini_config("$SSSD_CONF $SSSD_CONF_DIR/*.conf", "pam", "offline_credentials_expiration", "1") }}}
1320
1421
umask $OLD_UMASK

0 commit comments

Comments
 (0)