File: template_ANSIBLE_audit_rules_file_deletion_events

package info (click to toggle)
scap-security-guide 0.1.39-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 31,836 kB
  • sloc: xml: 129,736; python: 7,462; sh: 3,796; makefile: 27
file content (86 lines) | stat: -rw-r--r-- 2,499 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# 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 DAC audit rules
  find:
    paths: "/etc/audit/rules.d"
    recurse: no
    contains: "-F key=delete$"
    patterns: "*.rules"
  register: find_%NAME%

- name: If existing DAC ruleset not found, use /etc/audit/rules.d/delete.rules as the recipient for the rule
  set_fact:
    all_files: 
      - /etc/audit/rules.d/delete.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: "-a always,exit -F arch=b32 -S %NAME% -F auid>=1000 -F auid!=4294967295 -F key=delete"
    create: yes
  tags:
    @ANSIBLE_TAGS@

- name: Inserts/replaces the %NAME% rule in rules.d when on x86_64
  lineinfile:
    path: "{{ all_files[0] }}"
    line: "-a always,exit -F arch=b64 -S %NAME% -F auid>=1000 -F auid!=4294967295 -F key=delete"
    create: yes
  when: audit_arch == 'b64'
  tags:
    @ANSIBLE_TAGS@

- name: Inserts/replaces the %NAME% rule in rules.d when on x86
  lineinfile:
    path: "{{ all_files[0] }}"
    line: "-a always,exit -F arch=b32 -S %NAME% -F auid>=1000 -F auid!=4294967295 -F key=delete"
    create: yes
  when: audit_arch == 'b32'
  tags:
    @ANSIBLE_TAGS@
#    
# Inserts/replaces the rule in /etc/audit/audit.rules
#
- name: Inserts/replaces the %NAME% rule in /etc/audit/audit.rules when on x86
  lineinfile:
    line: "{{ item }}"
    state: present
    dest: /etc/audit/audit.rules
  with_items:
    - "-a always,exit -F arch=b32 -S %NAME% -F auid>=1000 -F auid!=4294967295 -F key=delete"
  when: audit_arch == 'b32'
  tags:
    @ANSIBLE_TAGS@

- name: Inserts/replaces the %NAME% rule in audit.rules when on x86_64
  lineinfile:
    line: "{{ item }}"
    state: present
    dest: /etc/audit/audit.rules
    create: yes
  with_items:
    - "-a always,exit -F arch=b64 -S %NAME% -F auid>=1000 -F auid!=4294967295 -F key=delete"
  when: audit_arch == 'b64'
  tags:
    @ANSIBLE_TAGS@