2022-07-08 22:52:58 +00:00
|
|
|
---
|
|
|
|
- name: Verify
|
|
|
|
hosts: all
|
|
|
|
become: true
|
|
|
|
environment:
|
|
|
|
http_proxy: "{{ lookup('env', 'http_proxy') | default(omit) }}"
|
|
|
|
https_proxy: "{{ lookup('env', 'https_proxy') | default(omit) }}"
|
|
|
|
no_proxy: "{{ lookup('env', 'no_proxy') | default(omit) }}"
|
|
|
|
tasks:
|
2023-12-06 13:37:09 +00:00
|
|
|
# temp. disabled - https://github.com/dev-sec/ansible-collection-hardening/issues/690
|
|
|
|
# - name: Include PAM tests
|
|
|
|
# ansible.builtin.include_tasks: verify_tasks/pam.yml
|
|
|
|
# when: ansible_facts.distribution in ['Debian', 'Ubuntu'] or ansible_facts.os_family == 'RedHat'
|
2022-07-08 22:52:58 +00:00
|
|
|
|
2023-12-06 10:18:56 +00:00
|
|
|
- name: Include YUM tests
|
|
|
|
ansible.builtin.include_tasks: verify_tasks/yum.yml
|
2022-07-08 22:52:58 +00:00
|
|
|
when: ansible_facts.os_family == 'RedHat'
|
|
|
|
|
2023-04-10 21:22:41 +00:00
|
|
|
- name: Verify
|
|
|
|
hosts: localhost
|
|
|
|
environment:
|
|
|
|
http_proxy: "{{ lookup('env', 'http_proxy') | default(omit) }}"
|
|
|
|
https_proxy: "{{ lookup('env', 'https_proxy') | default(omit) }}"
|
|
|
|
no_proxy: "{{ lookup('env', 'no_proxy') | default(omit) }}"
|
|
|
|
tasks:
|
2023-12-06 10:18:56 +00:00
|
|
|
- name: Get ssh-config
|
|
|
|
ansible.builtin.command:
|
2023-12-06 13:37:09 +00:00
|
|
|
cmd: vagrant ssh-config
|
2023-04-10 21:22:41 +00:00
|
|
|
chdir: "{{ molecule_ephemeral_directory }}"
|
|
|
|
register: ssh_config
|
|
|
|
changed_when: false
|
2022-07-08 22:52:58 +00:00
|
|
|
|
2023-12-06 10:18:56 +00:00
|
|
|
- name: Create ssh-config file
|
2023-12-06 13:37:09 +00:00
|
|
|
ansible.builtin.copy:
|
2023-04-10 21:22:41 +00:00
|
|
|
content: "{{ ssh_config.stdout_lines | join ('\n') }}"
|
|
|
|
dest: "{{ molecule_ephemeral_directory }}/ssh-config"
|
2023-12-06 14:27:21 +00:00
|
|
|
mode: "0400"
|
2023-04-10 21:22:41 +00:00
|
|
|
changed_when: false
|
2022-07-08 22:52:58 +00:00
|
|
|
|
2023-04-10 21:22:41 +00:00
|
|
|
- name: Execute cinc-auditor tests
|
2023-12-06 10:18:56 +00:00
|
|
|
ansible.builtin.command: >
|
2024-02-04 09:54:22 +00:00
|
|
|
docker run --rm
|
2023-04-10 21:22:41 +00:00
|
|
|
--volume {{ molecule_ephemeral_directory }}:{{ molecule_ephemeral_directory }}
|
|
|
|
docker.io/cincproject/auditor exec
|
|
|
|
--ssh-config-file={{ molecule_ephemeral_directory }}/ssh-config
|
|
|
|
-t ssh://{{ lookup('env', 'USER') }}
|
|
|
|
--sudo --no-show-progress --no-color
|
|
|
|
--no-distinct-exit https://github.com/dev-sec/linux-baseline/archive/refs/heads/master.zip
|
2022-07-08 22:52:58 +00:00
|
|
|
register: test_results
|
|
|
|
changed_when: false
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: Display details about the cinc-auditor results
|
2023-12-06 10:18:56 +00:00
|
|
|
ansible.builtin.debug:
|
2022-07-08 22:52:58 +00:00
|
|
|
msg: "{{ test_results.stdout_lines }}"
|
|
|
|
|
|
|
|
- name: Fail when tests fail
|
2023-12-06 10:18:56 +00:00
|
|
|
ansible.builtin.fail:
|
2023-12-06 13:37:09 +00:00
|
|
|
msg: Inspec failed to validate
|
2022-07-08 22:52:58 +00:00
|
|
|
when: test_results.rc != 0
|