2022-01-07 09:06:18 +00:00
|
|
|
---
|
|
|
|
|
|
2023-11-21 09:49:36 +00:00
|
|
|
- name: Pre Audit Setup | Setup the LE audit
|
2022-01-07 09:06:18 +00:00
|
|
|
when:
|
2023-07-28 15:16:50 +01:00
|
|
|
- setup_audit
|
2022-01-07 09:06:18 +00:00
|
|
|
tags:
|
2023-07-28 15:16:50 +01:00
|
|
|
- setup_audit
|
2023-11-21 09:49:36 +00:00
|
|
|
ansible.builtin.include_tasks: LE_audit_setup.yml
|
2022-01-07 09:06:18 +00:00
|
|
|
|
2023-11-21 09:49:36 +00:00
|
|
|
- name: Pre Audit Setup | Ensure {{ audit_conf_dir }} exists
|
2023-01-13 12:10:18 +00:00
|
|
|
ansible.builtin.file:
|
2022-01-07 09:06:18 +00:00
|
|
|
path: "{{ audit_conf_dir }}"
|
|
|
|
|
state: directory
|
|
|
|
|
mode: '0755'
|
|
|
|
|
|
2023-07-28 15:16:50 +01:00
|
|
|
- name: Pre Audit Setup | If using git for content set up
|
2023-11-21 09:49:36 +00:00
|
|
|
when:
|
|
|
|
|
- audit_content == 'git'
|
2023-07-28 15:16:50 +01:00
|
|
|
block:
|
|
|
|
|
- name: Pre Audit Setup | Install git
|
|
|
|
|
ansible.builtin.package:
|
|
|
|
|
name: git
|
|
|
|
|
state: present
|
2022-01-07 09:06:18 +00:00
|
|
|
|
2023-11-21 09:49:36 +00:00
|
|
|
- name: Pre Audit Setup | Retrieve audit content files from git
|
2023-07-28 15:16:50 +01:00
|
|
|
ansible.builtin.git:
|
|
|
|
|
repo: "{{ audit_file_git }}"
|
|
|
|
|
dest: "{{ audit_conf_dir }}"
|
|
|
|
|
version: "{{ audit_git_version }}"
|
2023-03-13 14:04:38 +00:00
|
|
|
|
2023-11-21 09:49:36 +00:00
|
|
|
- name: Pre Audit Setup | Copy to audit content files to server
|
|
|
|
|
when:
|
|
|
|
|
- audit_content == 'copy'
|
2023-01-13 12:10:18 +00:00
|
|
|
ansible.builtin.copy:
|
2023-12-05 19:51:38 +02:00
|
|
|
src: "{{ audit_conf_copy }}"
|
|
|
|
|
dest: "{{ audit_conf_dir }}"
|
2023-07-28 15:16:50 +01:00
|
|
|
mode: preserve
|
|
|
|
|
|
2023-11-21 09:49:36 +00:00
|
|
|
- name: Pre Audit Setup | Unarchive audit content files on server
|
|
|
|
|
when:
|
|
|
|
|
- audit_content == 'archived'
|
2023-07-28 15:16:50 +01:00
|
|
|
ansible.builtin.unarchive:
|
|
|
|
|
src: "{{ audit_conf_copy }}"
|
2022-01-07 09:06:18 +00:00
|
|
|
dest: "{{ audit_conf_dir }}"
|
|
|
|
|
|
2023-11-21 09:49:36 +00:00
|
|
|
- name: Pre Audit Setup | Get audit content from url
|
|
|
|
|
when:
|
|
|
|
|
- audit_content == 'get_url'
|
2023-01-13 12:10:18 +00:00
|
|
|
ansible.builtin.get_url:
|
2022-01-07 09:06:18 +00:00
|
|
|
url: "{{ audit_files_url }}"
|
|
|
|
|
dest: "{{ audit_conf_dir }}"
|
|
|
|
|
|
2023-07-28 15:16:50 +01:00
|
|
|
- name: Pre Audit Setup | Check Goss is available
|
2023-11-21 09:49:36 +00:00
|
|
|
when:
|
|
|
|
|
- run_audit
|
2022-01-07 09:06:18 +00:00
|
|
|
block:
|
2023-07-28 15:16:50 +01:00
|
|
|
- name: Pre Audit Setup | Check for goss file
|
|
|
|
|
ansible.builtin.stat:
|
|
|
|
|
path: "{{ audit_bin }}"
|
|
|
|
|
register: goss_available
|
2022-01-07 09:06:18 +00:00
|
|
|
|
2023-07-28 15:16:50 +01:00
|
|
|
- name: Pre Audit Setup | If audit ensure goss is available
|
|
|
|
|
when:
|
|
|
|
|
- not goss_available.stat.exists
|
2023-11-21 09:49:36 +00:00
|
|
|
ansible.builtin.assert:
|
|
|
|
|
msg: "Audit has been selected: unable to find goss binary at {{ audit_bin }}"
|
2022-01-07 09:06:18 +00:00
|
|
|
|
2023-07-28 15:16:50 +01:00
|
|
|
- name: Pre Audit Setup | Copy ansible default vars values to test audit
|
2023-11-21 09:49:36 +00:00
|
|
|
tags:
|
|
|
|
|
- goss_template
|
|
|
|
|
- run_audit
|
|
|
|
|
when:
|
|
|
|
|
- run_audit
|
2023-01-13 12:10:18 +00:00
|
|
|
ansible.builtin.template:
|
2022-01-07 09:06:18 +00:00
|
|
|
src: ansible_vars_goss.yml.j2
|
|
|
|
|
dest: "{{ audit_vars_path }}"
|
2023-09-21 16:25:59 +01:00
|
|
|
mode: '0600'
|
2022-01-07 09:06:18 +00:00
|
|
|
|
2023-11-21 09:49:36 +00:00
|
|
|
- name: Pre Audit | Run pre_remediation {{ benchmark }} audit
|
2023-01-13 12:10:18 +00:00
|
|
|
ansible.builtin.shell: "{{ audit_conf_dir }}/run_audit.sh -v {{ audit_vars_path }} -o {{ pre_audit_outfile }} -g {{ group_names }}"
|
2023-07-28 15:16:50 +01:00
|
|
|
changed_when: true
|
|
|
|
|
environment:
|
|
|
|
|
AUDIT_BIN: "{{ audit_bin }}"
|
|
|
|
|
AUDIT_CONTENT_LOCATION: "{{ audit_out_dir }}"
|
2023-11-21 09:49:36 +00:00
|
|
|
AUDIT_FILE: goss.yml
|
2022-01-07 09:06:18 +00:00
|
|
|
|
|
|
|
|
- name: Pre Audit | Capture audit data if json format
|
2023-11-21 09:49:36 +00:00
|
|
|
when:
|
|
|
|
|
- audit_format == "json"
|
2022-01-07 09:06:18 +00:00
|
|
|
block:
|
2023-11-21 09:49:36 +00:00
|
|
|
- name: capture data {{ pre_audit_outfile }}
|
|
|
|
|
ansible.builtin.shell: cat {{ pre_audit_outfile }}
|
2023-07-28 15:16:50 +01:00
|
|
|
register: pre_audit
|
|
|
|
|
changed_when: false
|
2022-01-07 09:06:18 +00:00
|
|
|
|
2023-07-28 15:16:50 +01:00
|
|
|
- name: Pre Audit | Capture pre-audit result
|
|
|
|
|
ansible.builtin.set_fact:
|
2024-02-20 15:43:43 +00:00
|
|
|
pre_audit_summary: "{{ pre_audit.stdout | from_json | community.general.json_query(summary) }}"
|
2023-07-28 15:16:50 +01:00
|
|
|
vars:
|
2023-11-21 09:49:36 +00:00
|
|
|
summary: summary."summary-line"
|
2022-01-07 09:06:18 +00:00
|
|
|
|
|
|
|
|
- name: Pre Audit | Capture audit data if documentation format
|
2023-11-21 09:49:36 +00:00
|
|
|
when:
|
|
|
|
|
- audit_format == "documentation"
|
2022-01-07 09:06:18 +00:00
|
|
|
block:
|
2023-11-21 09:49:36 +00:00
|
|
|
- name: Pre Audit | capture data {{ pre_audit_outfile }} | documentation format
|
|
|
|
|
ansible.builtin.shell: tail -2 {{ pre_audit_outfile }}
|
2023-07-28 15:16:50 +01:00
|
|
|
register: pre_audit
|
|
|
|
|
changed_when: false
|
2022-01-07 09:06:18 +00:00
|
|
|
|
2023-07-28 15:16:50 +01:00
|
|
|
- name: Pre Audit | Capture pre-audit result | documentation format
|
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
|
pre_audit_summary: "{{ pre_audit.stdout_lines }}"
|
2023-11-21 09:49:36 +00:00
|
|
|
|
|
|
|
|
- name: Audit_Only | Run Audit Only
|
2022-01-07 09:06:18 +00:00
|
|
|
when:
|
2023-11-21 09:49:36 +00:00
|
|
|
- audit_only
|
|
|
|
|
ansible.builtin.import_tasks: audit_only.yml
|