forked from ansible-lockdown/RHEL9-CIS
update audit output and remove jmespath
Signed-off-by: Mark Bolwell <mark.bollyuk@gmail.com>
This commit is contained in:
parent
7dcb2cae1c
commit
54e4ee1588
3 changed files with 24 additions and 27 deletions
|
|
@ -21,26 +21,24 @@
|
||||||
when:
|
when:
|
||||||
- audit_format == "json"
|
- audit_format == "json"
|
||||||
block:
|
block:
|
||||||
- name: capture data {{ post_audit_outfile }}
|
- name: Post Audit | Capture audit data if json format
|
||||||
ansible.builtin.shell: "cat {{ post_audit_outfile }}"
|
ansible.builtin.shell: grep -E '"summary-line.*Count:.*Failed' "{{ post_audit_outfile }}" | cut -d'"' -f4
|
||||||
register: post_audit
|
register: post_audit_summary
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Capture post-audit result
|
- name: Post Audit | Set Fact for audit summary
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
post_audit_summary: "{{ post_audit.stdout | from_json | json_query(summary) }}"
|
post_audit_results: "{{ post_audit_summary.stdout }}"
|
||||||
vars:
|
|
||||||
summary: summary."summary-line"
|
|
||||||
|
|
||||||
- name: Post Audit | Capture audit data if documentation format
|
- name: Post Audit | Capture audit data if documentation format
|
||||||
when:
|
when:
|
||||||
- audit_format == "documentation"
|
- audit_format == "documentation"
|
||||||
block:
|
block:
|
||||||
- name: Post Audit | capture data {{ post_audit_outfile }}
|
- name: Post Audit | Capture audit data if documentation format
|
||||||
ansible.builtin.shell: "tail -2 {{ post_audit_outfile }}"
|
ansible.builtin.shell: "tail -2 /opt/audit_ubuntu2204-CIS-UBUNTU22_1720624848.documentation"
|
||||||
register: post_audit
|
register: post_audit_summary
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Post Audit | Capture post-audit result
|
- name: Post Audit | Set Fact for audit summary
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
post_audit_summary: "{{ post_audit.stdout_lines }}"
|
post_audit_results: "{{ post_audit_summary.stdout }}"
|
||||||
|
|
|
||||||
|
|
@ -90,31 +90,30 @@
|
||||||
when:
|
when:
|
||||||
- audit_format == "json"
|
- audit_format == "json"
|
||||||
block:
|
block:
|
||||||
- name: Pre Audit | Capture data {{ pre_audit_outfile }}
|
- name: Pre Audit | Capture audit data if json format
|
||||||
ansible.builtin.shell: "cat {{ pre_audit_outfile }}"
|
ansible.builtin.shell: grep -E '\"summary-line.*Count:.*Failed' "{{ pre_audit_outfile }}" | cut -d'"' -f4
|
||||||
register: pre_audit
|
register: pre_audit_summary
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Pre Audit | Capture pre-audit result
|
- name: Pre Audit | Set Fact for audit summary
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
pre_audit_summary: "{{ pre_audit.stdout | from_json | json_query(summary) }}"
|
pre_audit_results: "{{ pre_audit_summary.stdout }}"
|
||||||
vars:
|
|
||||||
summary: summary."summary-line"
|
|
||||||
|
|
||||||
- name: Pre Audit | Capture audit data if documentation format
|
- name: Pre Audit | Capture audit data if documentation format
|
||||||
when:
|
when:
|
||||||
- audit_format == "documentation"
|
- audit_format == "documentation"
|
||||||
block:
|
block:
|
||||||
- name: Pre Audit | Capture data {{ pre_audit_outfile }} | documentation format
|
- name: Pre Audit | Capture audit data if documentation format
|
||||||
ansible.builtin.shell: "tail -2 {{ pre_audit_outfile }}"
|
ansible.builtin.shell: tail -2 "{{ pre_audit_outfile }}" | tac | tr '\n' ' '
|
||||||
register: pre_audit
|
register: pre_audit_summary
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Pre Audit | Capture pre-audit result | documentation format
|
- name: Pre Audit | Set Fact for audit summary
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
pre_audit_summary: "{{ pre_audit.stdout_lines }}"
|
pre_audit_results: "{{ pre_audit_summary.stdout }}"
|
||||||
|
|
||||||
- name: Audit_Only | Run Audit Only
|
- name: Audit_Only | Run Audit Only
|
||||||
when:
|
when:
|
||||||
- audit_only
|
- audit_only
|
||||||
ansible.builtin.import_tasks: audit_only.yml
|
ansible.builtin.import_tasks:
|
||||||
|
file: audit_only.yml
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ audit_format: json
|
||||||
|
|
||||||
audit_vars_path: "{{ audit_conf_dir }}/vars/{{ ansible_facts.hostname }}.yml"
|
audit_vars_path: "{{ audit_conf_dir }}/vars/{{ ansible_facts.hostname }}.yml"
|
||||||
audit_results: |
|
audit_results: |
|
||||||
The audit results are: {{ pre_audit_summary }}
|
The{% if not audit_only %} pre remediation{% endif %} audit results are: {{ pre_audit_results}}
|
||||||
{% if not audit_only %}The post remediation audit results are: {{ post_audit_summary }}{% endif %}
|
{% if not audit_only %}The post remediation audit results are: {{ post_audit_results }}{% endif %}
|
||||||
|
|
||||||
Full breakdown can be found in {{ audit_log_dir }}
|
Full breakdown can be found in {{ audit_log_dir }}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue