File: template_ANSIBLE_audit_rules_usergroup_modification

package info (click to toggle)
scap-security-guide 0.1.39-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 31,836 kB
  • sloc: xml: 129,736; python: 7,462; sh: 3,796; makefile: 27
file content (56 lines) | stat: -rw-r--r-- 1,573 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
# platform = multi_platform_rhel,multi_platform_fedora
# reboot = true
# strategy = restrict
# complexity = low
# disruption = low

#
# What architecture are we on?
#
- name: Set architecture for audit %NAME% tasks
  set_fact:
    audit_arch: "b{{ ansible_architecture | regex_replace('.*(\\d\\d$)','\\1') }}"

#
# Inserts/replaces the rule in /etc/audit/rules.d
#
- name: Search /etc/audit/rules.d for other user/group modification audit rules
  find:
    paths: "/etc/audit/rules.d"
    recurse: no
    contains: "-k audit_rules_usergroup_modification$"
    patterns: "*.rules"
  register: find_%NAME%

- name: If existing user/group modification ruleset not found, use /etc/audit/rules.d/privileged.rules as the recipient for the rule
  set_fact:
    all_files: 
      - /etc/audit/rules.d/privileged.rules
  when: find_%NAME%.matched == 0

- name: Use matched file as the recipient for the rule
  set_fact:
    all_files:
      - "{{ find_%NAME%.files | map(attribute='path') | list | first }}"
  when: find_%NAME%.matched > 0

- name: Inserts/replaces the %NAME% rule in rules.d when on x86
  lineinfile:
    path: "{{ all_files[0] }}"
    line: "-w %PATH% -p wa -k audit_rules_usergroup_modification"
    create: yes
  tags:
    @ANSIBLE_TAGS@

#    
# Inserts/replaces the rule in /etc/audit/audit.rules
#
- name: Inserts/replaces the %NAME% rule in /etc/audit/audit.rules 
  lineinfile:
    line: "{{ item }}"
    state: present
    dest: /etc/audit/audit.rules
  with_items:
    - "-w %PATH% -p wa -k audit_rules_usergroup_modification"
  tags:
    @ANSIBLE_TAGS@