File: ansible.template

package info (click to toggle)
scap-security-guide 0.1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 110,644 kB
  • sloc: xml: 241,883; sh: 73,777; python: 32,527; makefile: 27
file content (65 lines) | stat: -rw-r--r-- 1,888 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
56
57
58
59
60
61
62
63
64
65
# platform = multi_platform_all
# reboot = true
# strategy = disable
# complexity = low
# disruption = medium

- name: List /etc/sysctl.d/*.conf files
{{% if product in ["sle12", "sle15", "slmicro5"] %}}
  find:
    paths:
      - "/run/sysctl.d/"
      - "/etc/sysctl.d/"
      - "/usr/local/lib/sysctl.d/"
      - "/lib/sysctl.d/"
{{% else %}}
  find:
    paths:
      - "/etc/sysctl.d/"
      - "/run/sysctl.d/"
      - "/usr/local/lib/sysctl.d/"
{{% endif %}}
{{% if product not in [ "ol7", "ol8", "ol9", "rhcos4", "rhel8", "rhel9", "rhel10", "sle12", "sle15", "slmicro5", "ubuntu2004", "ubuntu2204", "ubuntu2404"] %}}
      - "/usr/lib/sysctl.d/"
{{% endif %}}
    contains: '^[\s]*{{{ SYSCTLVAR }}}.*$'
    patterns: "*.conf"
    file_type: any
  register: find_sysctl_d

- name: Comment out any occurrences of {{{ SYSCTLVAR }}} from config files
  replace:
    path: "{{ item.path }}"
    regexp: '^[\s]*{{{ SYSCTLVAR }}}'
    replace: '#{{{ SYSCTLVAR }}}'
  loop: "{{ find_sysctl_d.files }}"

{{% if sysctl_remediate_drop_in_file == "true" %}}
- name: Comment out any occurrences of {{{ SYSCTLVAR }}} from /etc/sysctl.conf
  replace:
    path: "/etc/sysctl.conf"
    regexp: '^[\s]*{{{ SYSCTLVAR }}}'
    replace: '#{{{ SYSCTLVAR }}}'
{{% endif %}}

{{%- if SYSCTLVAL == "" or SYSCTLVAL is not string  %}}
- (xccdf-var sysctl_{{{ SYSCTLID }}}_value)

- name: Ensure sysctl {{{ SYSCTLVAR }}} is set
  sysctl:
    name: "{{{ SYSCTLVAR }}}"
    value: "{{ sysctl_{{{ SYSCTLID }}}_value }}"
{{%- else %}}
- name: Ensure sysctl {{{ SYSCTLVAR }}} is set to {{{ SYSCTLVAL }}}
  sysctl:
    name: "{{{ SYSCTLVAR }}}"
    value: "{{{ SYSCTLVAL }}}"
{{%- endif %}}
{{% if sysctl_remediate_drop_in_file == "true" %}}
    sysctl_file: "/etc/sysctl.d/{{{ SYSCTLVAR | replace('.','_') }}}.conf"
{{% else %}}
    sysctl_file: "/etc/sysctl.conf"
{{% endif %}}
    state: present
    reload: yes