File: shared.yml

package info (click to toggle)
scap-security-guide 0.1.78-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 114,600 kB
  • sloc: xml: 245,305; sh: 84,381; python: 33,093; makefile: 27
file content (55 lines) | stat: -rw-r--r-- 1,932 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# platform = multi_platform_all
# reboot = false
# strategy = configure
# complexity = low
# disruption = medium

- name: {{{ rule_title }}} - Find all the conf files inside the /etc/sssd/conf.d/ directory
  ansible.builtin.find:
    paths:
    - "/etc/sssd/conf.d/"
    patterns: "*.conf"
  register: sssd_conf_d_files

- name: {{{ rule_title }}} - Modify lines in files in the /etc/sssd/conf.d/ directory
  ansible.builtin.replace:
    path: "{{ item }}"
    regexp: '^(\s*\[sssd\].*(?:\n\s*[^[\s].*)*\n\s*services\s*=(?!.*\bpam\b).*)$'
    replace: '\1,pam'
  with_items: "{{ sssd_conf_d_files.files | map(attribute='path') }}"
  register: modify_lines_sssd_conf_d_files
  when: sssd_conf_d_files.matched is defined and sssd_conf_d_files.matched >= 1

- name: {{{ rule_title }}} - Find /etc/sssd/sssd.conf
  ansible.builtin.stat:
    path: /etc/sssd/sssd.conf
  register: sssd_conf_file

- name: {{{ rule_title }}} - Modify lines in /etc/sssd/sssd.conf
  ansible.builtin.replace:
    path: "/etc/sssd/sssd.conf"
    regexp: '^(\s*\[sssd\].*(?:\n\s*[^[\s].*)*\n\s*services\s*=(?!.*\bpam\b).*)$'
    replace: '\1,pam'
  register: modify_lines_sssd_conf_file
  when: sssd_conf_file.stat.exists

- name: {{{ rule_title }}} - Find services key in /etc/sssd/sssd.conf
  ansible.builtin.replace:
    path: "/etc/sssd/sssd.conf"
    regexp: '^\s*\[sssd\][^\[\]]*?(?:\n(?!\[)[^\n]*?services\s*=)+'
    replace: ''
  changed_when: false
  check_mode: true
  register: sssd_conf_file_services
  when: sssd_conf_file.stat.exists

- name: {{{ rule_title }}} - Insert entry to /etc/sssd/sssd.conf
  community.general.ini_file:
    path: /etc/sssd/sssd.conf
    section: sssd
    option: services
    value: pam
  when:
  - not modify_lines_sssd_conf_d_files.changed
  - not modify_lines_sssd_conf_file.changed
  - (sssd_conf_file_services.msg is defined and "replacements" not in sssd_conf_file_services.msg) or not sssd_conf_file.stat.exists