mirror of
https://github.com/ansible-lockdown/RHEL9-CIS.git
synced 2025-12-24 22:23:06 +00:00
section1 v2 initial
Signed-off-by: Mark Bolwell <mark.bollyuk@gmail.com>
This commit is contained in:
parent
cf4376f1f7
commit
8b58d71e4b
47 changed files with 2181 additions and 1707 deletions
|
|
@ -2,118 +2,118 @@
|
|||
|
||||
- name: Pre Audit Setup | Setup the LE audit
|
||||
when:
|
||||
- setup_audit
|
||||
- setup_audit
|
||||
tags:
|
||||
- setup_audit
|
||||
- setup_audit
|
||||
ansible.builtin.include_tasks:
|
||||
file: LE_audit_setup.yml
|
||||
file: LE_audit_setup.yml
|
||||
|
||||
- name: Pre Audit Setup | Ensure {{ audit_conf_dir }} exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ audit_conf_dir }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
path: "{{ audit_conf_dir }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
- name: Pre Audit Setup | If using git for content set up
|
||||
when:
|
||||
- audit_content == 'git'
|
||||
- audit_content == 'git'
|
||||
block:
|
||||
- name: Pre Audit Setup | Install git
|
||||
ansible.builtin.package:
|
||||
name: git
|
||||
state: present
|
||||
- name: Pre Audit Setup | Install git
|
||||
ansible.builtin.package:
|
||||
name: git
|
||||
state: present
|
||||
|
||||
- name: Pre Audit Setup | Retrieve audit content files from git
|
||||
ansible.builtin.git:
|
||||
repo: "{{ audit_file_git }}"
|
||||
dest: "{{ audit_conf_dir }}"
|
||||
version: "{{ audit_git_version }}"
|
||||
- name: Pre Audit Setup | Retrieve audit content files from git
|
||||
ansible.builtin.git:
|
||||
repo: "{{ audit_file_git }}"
|
||||
dest: "{{ audit_conf_dir }}"
|
||||
version: "{{ audit_git_version }}"
|
||||
|
||||
- name: Pre Audit Setup | Copy to audit content files to server
|
||||
when:
|
||||
- audit_content == 'copy'
|
||||
- audit_content == 'copy'
|
||||
ansible.builtin.copy:
|
||||
src: "{{ audit_conf_source }}"
|
||||
dest: "{{ audit_conf_dest }}"
|
||||
mode: preserve
|
||||
src: "{{ audit_conf_source }}"
|
||||
dest: "{{ audit_conf_dest }}"
|
||||
mode: preserve
|
||||
|
||||
- name: Pre Audit Setup | Unarchive audit content files on server
|
||||
when:
|
||||
- audit_content == 'archive'
|
||||
- audit_content == 'archive'
|
||||
ansible.builtin.unarchive:
|
||||
src: "{{ audit_conf_source }}"
|
||||
dest: "{{ audit_conf_dest }}"
|
||||
src: "{{ audit_conf_source }}"
|
||||
dest: "{{ audit_conf_dest }}"
|
||||
|
||||
- name: Pre Audit Setup | Get audit content from url
|
||||
when:
|
||||
- audit_content == 'get_url'
|
||||
- audit_content == 'get_url'
|
||||
ansible.builtin.unarchive:
|
||||
src: "{{ audit_conf_source }}"
|
||||
dest: "{{ audit_conf_dest }}/{{ benchmark }}-Audit"
|
||||
remote_src: "{{ ( audit_conf_source is contains ('http'))| ternary(true, false ) }}"
|
||||
extra_opts: "{{ (audit_conf_source is contains ('github')) | ternary('--strip-components=1', [] ) }}"
|
||||
src: "{{ audit_conf_source }}"
|
||||
dest: "{{ audit_conf_dest }}/{{ benchmark }}-Audit"
|
||||
remote_src: "{{ ( audit_conf_source is contains ('http'))| ternary(true, false ) }}"
|
||||
extra_opts: "{{ (audit_conf_source is contains ('github')) | ternary('--strip-components=1', [] ) }}"
|
||||
|
||||
- name: Pre Audit Setup | Check Goss is available
|
||||
when:
|
||||
- run_audit
|
||||
- run_audit
|
||||
block:
|
||||
- name: Pre Audit Setup | Check for goss file
|
||||
ansible.builtin.stat:
|
||||
path: "{{ audit_bin }}"
|
||||
register: goss_available
|
||||
- name: Pre Audit Setup | Check for goss file
|
||||
ansible.builtin.stat:
|
||||
path: "{{ audit_bin }}"
|
||||
register: goss_available
|
||||
|
||||
- name: Pre Audit Setup | If audit ensure goss is available
|
||||
ansible.builtin.assert:
|
||||
that: goss_available.stat.exists
|
||||
msg: "Audit has been selected: unable to find goss binary at {{ audit_bin }}"
|
||||
- name: Pre Audit Setup | If audit ensure goss is available
|
||||
ansible.builtin.assert:
|
||||
that: goss_available.stat.exists
|
||||
msg: "Audit has been selected: unable to find goss binary at {{ audit_bin }}"
|
||||
|
||||
- name: Pre Audit Setup | Copy ansible default vars values to test audit
|
||||
tags:
|
||||
- goss_template
|
||||
- run_audit
|
||||
- goss_template
|
||||
- run_audit
|
||||
when:
|
||||
- run_audit
|
||||
- run_audit
|
||||
ansible.builtin.template:
|
||||
src: ansible_vars_goss.yml.j2
|
||||
dest: "{{ audit_vars_path }}"
|
||||
mode: '0600'
|
||||
src: ansible_vars_goss.yml.j2
|
||||
dest: "{{ audit_vars_path }}"
|
||||
mode: '0600'
|
||||
|
||||
- name: Pre Audit | Run pre_remediation {{ benchmark }} audit
|
||||
ansible.builtin.shell: "{{ audit_conf_dir }}/run_audit.sh -v {{ audit_vars_path }} -f {{ audit_format }} -o {{ pre_audit_outfile }} -g \"{{ group_names }}\""
|
||||
changed_when: true
|
||||
environment:
|
||||
AUDIT_BIN: "{{ audit_bin }}"
|
||||
AUDIT_CONTENT_LOCATION: "{{ audit_conf_dest | default('/opt') }}"
|
||||
AUDIT_FILE: goss.yml
|
||||
AUDIT_BIN: "{{ audit_bin }}"
|
||||
AUDIT_CONTENT_LOCATION: "{{ audit_conf_dest | default('/opt') }}"
|
||||
AUDIT_FILE: goss.yml
|
||||
|
||||
- name: Pre Audit | Capture audit data if json format
|
||||
when:
|
||||
- audit_format == "json"
|
||||
- audit_format == "json"
|
||||
block:
|
||||
- name: Pre Audit | Capture audit data if json format
|
||||
ansible.builtin.shell: grep -E '\"summary-line.*Count:.*Failed' "{{ pre_audit_outfile }}" | cut -d'"' -f4
|
||||
register: pre_audit_summary
|
||||
changed_when: false
|
||||
- name: Pre Audit | Capture audit data if json format
|
||||
ansible.builtin.shell: grep -E '\"summary-line.*Count:.*Failed' "{{ pre_audit_outfile }}" | cut -d'"' -f4
|
||||
register: pre_audit_summary
|
||||
changed_when: false
|
||||
|
||||
- name: Pre Audit | Set Fact for audit summary
|
||||
ansible.builtin.set_fact:
|
||||
pre_audit_results: "{{ pre_audit_summary.stdout }}"
|
||||
- name: Pre Audit | Set Fact for audit summary
|
||||
ansible.builtin.set_fact:
|
||||
pre_audit_results: "{{ pre_audit_summary.stdout }}"
|
||||
|
||||
- name: Pre Audit | Capture audit data if documentation format
|
||||
when:
|
||||
- audit_format == "documentation"
|
||||
- audit_format == "documentation"
|
||||
block:
|
||||
- name: Pre Audit | Capture audit data if documentation format
|
||||
ansible.builtin.shell: tail -2 "{{ pre_audit_outfile }}" | tac | tr '\n' ' '
|
||||
register: pre_audit_summary
|
||||
changed_when: false
|
||||
- name: Pre Audit | Capture audit data if documentation format
|
||||
ansible.builtin.shell: tail -2 "{{ pre_audit_outfile }}" | tac | tr '\n' ' '
|
||||
register: pre_audit_summary
|
||||
changed_when: false
|
||||
|
||||
- name: Pre Audit | Set Fact for audit summary
|
||||
ansible.builtin.set_fact:
|
||||
pre_audit_results: "{{ pre_audit_summary.stdout }}"
|
||||
- name: Pre Audit | Set Fact for audit summary
|
||||
ansible.builtin.set_fact:
|
||||
pre_audit_results: "{{ pre_audit_summary.stdout }}"
|
||||
|
||||
- name: Audit_Only | Run Audit Only
|
||||
when:
|
||||
- audit_only
|
||||
- audit_only
|
||||
ansible.builtin.import_tasks:
|
||||
file: audit_only.yml
|
||||
file: audit_only.yml
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue