|
4 | 4 | when: setup_audit |
5 | 5 | tags: setup_audit |
6 | 6 | ansible.builtin.include_tasks: |
7 | | - file: LE_audit_setup.yml |
| 7 | + file: LE_audit_setup.yml |
8 | 8 |
|
9 | 9 | - name: Pre Audit Setup | Ensure existence of {{ audit_conf_dir }} # noqa name[template] |
10 | 10 | ansible.builtin.file: |
11 | | - path: "{{ audit_conf_dir }}" |
12 | | - mode: 'go-w' |
13 | | - state: directory |
| 11 | + path: "{{ audit_conf_dir }}" |
| 12 | + mode: 'go-w' |
| 13 | + state: directory |
14 | 14 |
|
15 | 15 | - name: Pre Audit Setup | If using git for content set up |
16 | 16 | when: audit_content == 'git' |
17 | 17 | block: |
18 | | - - name: Pre Audit Setup | Install git |
19 | | - ansible.builtin.package: |
20 | | - name: git |
21 | | - state: present |
| 18 | + - name: Pre Audit Setup | Install git |
| 19 | + ansible.builtin.package: |
| 20 | + name: git |
| 21 | + state: present |
22 | 22 |
|
23 | | - - name: Pre Audit Setup | Retrieve audit content files from git |
24 | | - ansible.builtin.git: |
25 | | - repo: "{{ audit_file_git }}" |
26 | | - dest: "{{ audit_conf_dir }}" |
27 | | - version: "{{ audit_git_version }}" |
| 23 | + - name: Pre Audit Setup | Retrieve audit content files from git |
| 24 | + ansible.builtin.git: |
| 25 | + repo: "{{ audit_file_git }}" |
| 26 | + dest: "{{ audit_conf_dir }}" |
| 27 | + version: "{{ audit_git_version }}" |
28 | 28 |
|
29 | 29 | - name: Pre Audit Setup | Copy to audit content files to server |
30 | 30 | when: audit_content == 'copy' |
31 | 31 | ansible.builtin.copy: |
32 | | - src: "{{ audit_conf_source }}" |
33 | | - dest: "{{ audit_conf_dest }}" |
34 | | - mode: preserve |
| 32 | + src: "{{ audit_conf_source }}" |
| 33 | + dest: "{{ audit_conf_dest }}" |
| 34 | + mode: preserve |
35 | 35 |
|
36 | 36 | - name: Pre Audit Setup | Unarchive audit content files on server |
37 | 37 | when: audit_content == 'archive' |
38 | 38 | ansible.builtin.unarchive: |
39 | | - src: "{{ audit_conf_source }}" |
40 | | - dest: "{{ audit_conf_dest }}" |
| 39 | + src: "{{ audit_conf_source }}" |
| 40 | + dest: "{{ audit_conf_dest }}" |
41 | 41 |
|
42 | 42 | - name: Pre Audit Setup | Get audit content from url |
43 | 43 | when: audit_content == 'get_url' |
44 | 44 | ansible.builtin.unarchive: |
45 | | - src: "{{ audit_conf_source }}" |
46 | | - dest: "{{ audit_conf_dest }}/{{ benchmark }}-Audit" |
47 | | - remote_src: "{{ (audit_conf_source is contains('http')) | ternary(true, false) }}" |
48 | | - extra_opts: "{{ (audit_conf_source is contains('github')) | ternary('--strip-components=1', []) }}" |
| 45 | + src: "{{ audit_conf_source }}" |
| 46 | + dest: "{{ audit_conf_dest }}/{{ benchmark }}-Audit" |
| 47 | + remote_src: "{{ (audit_conf_source is contains('http')) | ternary(true, false) }}" |
| 48 | + extra_opts: "{{ (audit_conf_source is contains('github')) | ternary('--strip-components=1', []) }}" |
49 | 49 |
|
50 | 50 | - name: Pre Audit Setup | Check Goss is available |
51 | 51 | when: run_audit |
52 | 52 | block: |
53 | | - - name: Pre Audit Setup | Check for goss file |
54 | | - ansible.builtin.stat: |
55 | | - path: "{{ audit_bin }}" |
56 | | - register: prelim_goss_available |
| 53 | + - name: Pre Audit Setup | Check for goss file |
| 54 | + ansible.builtin.stat: |
| 55 | + path: "{{ audit_bin }}" |
| 56 | + register: prelim_goss_available |
57 | 57 |
|
58 | | - - name: Pre Audit Setup | If audit ensure goss is available |
59 | | - when: not prelim_goss_available.stat.exists |
60 | | - ansible.builtin.assert: |
61 | | - that: prelim_goss_available['stat']['exists'] == true |
62 | | - msg: "Audit has been selected: unable to find goss binary at {{ audit_bin }}" |
| 58 | + - name: Pre Audit Setup | If audit ensure goss is available |
| 59 | + when: not prelim_goss_available.stat.exists |
| 60 | + ansible.builtin.assert: |
| 61 | + that: prelim_goss_available['stat']['exists'] == true |
| 62 | + msg: "Audit has been selected: unable to find goss binary at {{ audit_bin }}" |
63 | 63 |
|
64 | 64 | - name: Pre Audit Setup | Copy ansible default vars values to test audit |
65 | 65 | when: run_audit |
66 | 66 | tags: |
67 | | - - goss_template |
68 | | - - run_audit |
| 67 | + - goss_template |
| 68 | + - run_audit |
69 | 69 | ansible.builtin.template: |
70 | | - src: ansible_vars_goss.yml.j2 |
71 | | - dest: "{{ audit_vars_path }}" |
72 | | - mode: 'go-rwx' |
| 70 | + src: ansible_vars_goss.yml.j2 |
| 71 | + dest: "{{ audit_vars_path }}" |
| 72 | + mode: 'go-rwx' |
73 | 73 |
|
74 | 74 | - name: Pre Audit | Run pre_remediation audit {{ benchmark }} # noqa name[template] |
75 | | - ansible.builtin.shell: "umask 0022 && {{ audit_conf_dir }}/run_audit.sh -v {{ audit_vars_path }} -f {{ audit_format }} -m {{ audit_max_concurrent }} -o {{ pre_audit_outfile }} -g \"{{ group_names }}\"" # noqa yaml[line-length] |
| 75 | + ansible.builtin.shell: "umask 0022 && {{ audit_conf_dir }}/run_audit.sh -v {{ audit_vars_path }} -f {{ audit_format }} -m {{ audit_max_concurrent }} -o {{ pre_audit_outfile }} -g \"{{ group_names }}\"" # noqa yaml[line-length] |
76 | 76 | changed_when: true |
77 | 77 | environment: |
78 | | - AUDIT_BIN: "{{ audit_bin }}" |
79 | | - AUDIT_CONTENT_LOCATION: "{{ audit_conf_dest | default('/opt') }}" |
80 | | - AUDIT_FILE: goss.yml |
| 78 | + AUDIT_BIN: "{{ audit_bin }}" |
| 79 | + AUDIT_CONTENT_LOCATION: "{{ audit_conf_dest | default('/opt') }}" |
| 80 | + AUDIT_FILE: goss.yml |
81 | 81 |
|
82 | 82 | - name: Pre Audit | Capture audit data if json format |
83 | 83 | when: audit_format == "json" |
84 | 84 | block: |
85 | | - - name: Pre Audit | Capture audit data if json format |
86 | | - ansible.builtin.shell: grep -E '\"summary-line.*Count:.*Failed' "{{ pre_audit_outfile }}" | cut -d'"' -f4 |
87 | | - changed_when: false |
88 | | - register: pre_audit_summary |
| 85 | + - name: Pre Audit | Capture audit data if json format |
| 86 | + ansible.builtin.shell: grep -E '\"summary-line.*Count:.*Failed' "{{ pre_audit_outfile }}" | cut -d'"' -f4 |
| 87 | + changed_when: false |
| 88 | + register: pre_audit_summary |
89 | 89 |
|
90 | | - - name: Pre Audit | Set Fact for audit summary |
91 | | - ansible.builtin.set_fact: |
92 | | - pre_audit_results: "{{ pre_audit_summary.stdout }}" |
| 90 | + - name: Pre Audit | Set Fact for audit summary |
| 91 | + ansible.builtin.set_fact: |
| 92 | + pre_audit_results: "{{ pre_audit_summary.stdout }}" |
93 | 93 |
|
94 | 94 | - name: Pre Audit | Capture audit data if documentation format |
95 | 95 | when: audit_format == "documentation" |
96 | 96 | block: |
97 | | - - name: Pre Audit | Capture audit data if documentation format |
98 | | - ansible.builtin.shell: tail -2 "{{ pre_audit_outfile }}" | tac | tr '\n' ' ' |
99 | | - changed_when: false |
100 | | - register: pre_audit_summary |
| 97 | + - name: Pre Audit | Capture audit data if documentation format |
| 98 | + ansible.builtin.shell: tail -2 "{{ pre_audit_outfile }}" | tac | tr '\n' ' ' |
| 99 | + changed_when: false |
| 100 | + register: pre_audit_summary |
101 | 101 |
|
102 | | - - name: Pre Audit | Set Fact for audit summary |
103 | | - ansible.builtin.set_fact: |
104 | | - pre_audit_results: "{{ pre_audit_summary.stdout }}" |
| 102 | + - name: Pre Audit | Set Fact for audit summary |
| 103 | + ansible.builtin.set_fact: |
| 104 | + pre_audit_results: "{{ pre_audit_summary.stdout }}" |
105 | 105 |
|
106 | 106 | - name: Audit_Only | Run Audit Only |
107 | 107 | when: audit_only |
108 | 108 | ansible.builtin.import_tasks: |
109 | | - file: audit_only.yml |
| 109 | + file: audit_only.yml |
0 commit comments