-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* removed V-38635 per V1R16 * add vagrant testing for local dev/etc * add fix for #112 - non idempotent task * update README to reflect V1R16 change
- Loading branch information
1 parent
e4e266f
commit 3c4025a
Showing
11 changed files
with
200 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
RHEL 6 DISA STIG Testing | ||
================ | ||
Local testing of this role can be accomplished easily by using Vagrant. The included Vagrantfile has box definitions for a CentOS 6 and RHEL 6 based test machine. Additionally there are various playbooks in this directory for applying the STIG role to the boxes and there is a provision step in the Vagrantfile that will apply the role when the machine boots. | ||
|
||
Testing the idempotence of the role can be acomplished by running the role_idempotent_check.yml playbook | ||
|
||
Requirements | ||
------------ | ||
vagrant>=2.0 | ||
|
||
ansible>=2.4.0.0 | ||
|
||
Galaxy Roles | ||
|
||
samdoran.redhat-subscription | ||
|
||
```shell | ||
ansible-galaxy install -r requirements.yml | ||
``` | ||
|
||
`vagrant-inventory` file with proper values in it. | ||
```ini | ||
[baseline_hosts] | ||
centos6 ansible_port=2200 ansible_ssh_private_key_file=.vagrant/machines/centos6-stig/virtualbox/private_key | ||
rhel6 ansible_port=2201 ansible_ssh_private_key_file=.vagrant/machines/rhel6-stig/virtualbox/private_key | ||
|
||
[baseline_hosts:vars] | ||
ansible_host=127.0.0.1 | ||
ansible_user=vagrant | ||
``` | ||
|
||
Example Testing | ||
----------------- | ||
|
||
Spin up a new CentOS and RHEL box in Vagrant to run the tests on and apply the STIG. | ||
|
||
```shell | ||
vagrant up | ||
``` | ||
|
||
Or if you don't want to run the initial provision steps at this time. | ||
|
||
```shell | ||
vagrant up --no-provision | ||
``` | ||
|
||
Not running the provision steps in vagrant is sometimes preferred because vagrant will not run the play in parallel on both hosts, it will run on each host in serial. | ||
|
||
If you did not provision in the above step then run Ansible to provision the host. | ||
|
||
```shell | ||
ansible-playbook -i vagrant-inventory apply_role.yml -e @extra_vars_vagrant.yml | ||
``` | ||
|
||
If there are no failures then we want apply the role again and test for idempotence. | ||
|
||
```shell | ||
ansible-playbook -i vagrant-inventory role_idempotent_check.yml | ||
``` | ||
The idempotence check playbook runs the STIG role in silent mode (redirecting play/task output to JSON). You will not see each individual task run and it will take ~5min to complete. | ||
|
||
After you are done you may see output like below if the idempotence check fails. The `assert` tasks give pass or fail for CentOS 6 and RHEL 6 respectively and give a list of the non-idempotent tasks from the run. | ||
|
||
``` | ||
TASK [assert] ****************************************************************** | ||
fatal: [centos6]: FAILED! => { | ||
"assertion": "play_output.stats.centos6.changed == 0", | ||
"changed": false, | ||
"evaluated_to": false, | ||
"failed": true, | ||
"msg": "Role FAILED idempotent test on CentOS6: [u'MEDIUM | V-51363 | PATCH | The system must use a Linux Security Module configured to enforce limits on system services.', u'LOW | V-51369 | PATCH | The system must use a Linux Security Module configured to limit the privileges of system services.'] tasks reported change on second run." | ||
} | ||
fatal: [rhel6]: FAILED! => { | ||
"assertion": "play_output.stats.centos6.changed == 0", | ||
"changed": false, | ||
"evaluated_to": false, | ||
"failed": true, | ||
"msg": "Role FAILED idempotent test on CentOS6: [u'MEDIUM | V-51363 | PATCH | The system must use a Linux Security Module configured to enforce limits on system services.', u'LOW | V-38567 | PATCH | The audit system must be configured to audit all use of setuid and setgid programs.', u'LOW | V-51369 | PATCH | The system must use a Linux Security Module configured to limit the privileges of system services.'] tasks reported change on second run." | ||
} | ||
PLAY RECAP ****************************************************************** | ||
centos6 : ok=5 changed=1 unreachable=0 failed=1 | ||
rhel6 : ok=5 changed=1 unreachable=0 failed=1 | ||
``` | ||
|
||
After you are done you should clean up. | ||
|
||
```shell | ||
ansible-playbook -i vagrant-inventory deregister.yml | ||
vagrant destroy -f | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
- name: Apply STIG | ||
hosts: baseline_hosts | ||
become: yes | ||
|
||
tasks: | ||
- name: Register system with RedHat | ||
include_role: | ||
name: redhat-subscription | ||
when: ansible_distribution == 'RedHat' | ||
|
||
- name: Remove EPEL | ||
yum: | ||
name: epel-release | ||
state: absent | ||
|
||
- name: Apply STIG | ||
include_role: | ||
name: ../../RHEL6-STIG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
- name: Red Hat subscription state | ||
hosts: all | ||
become: yes | ||
|
||
vars: | ||
rhsub_state: absent | ||
|
||
tasks: | ||
- include_role: | ||
name: redhat-subscription | ||
when: ansible_distribution == 'RedHat' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
rhel6stig_cat1: yes | ||
rhel6stig_cat2: yes | ||
rhel6stig_cat3: yes | ||
|
||
rhel6stig_antivirus_required: no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- src: samdoran.redhat-subscription | ||
name: redhat-subscription |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
- name: Tets role idempotence | ||
hosts: baseline_hosts | ||
become: yes | ||
|
||
vars: | ||
extra_vars_file: extra_vars_vagrant.yml | ||
|
||
tasks: | ||
- name: Apply STIG - idempotence test - SILENT OUTPUT | ||
shell: "ansible-playbook -i vagrant-inventory apply_role.yml -e @{{extra_vars_file}}" | ||
environment: | ||
ANSIBLE_STDOUT_CALLBACK: json | ||
delegate_to: localhost | ||
become: no | ||
register: run_result | ||
|
||
- set_fact: | ||
play_output: "{{run_result.stdout|from_json}}" | ||
|
||
- set_fact: | ||
centos6_changed: "{{play_output|json_query('plays[].tasks[?hosts.centos6.changed].task.name')}}" | ||
|
||
- set_fact: | ||
rhel6_changed: "{{play_output|json_query('plays[].tasks[?hosts.centos6.changed].task.name')}}" | ||
|
||
- assert: | ||
that: | ||
- "play_output.stats.centos6.changed == 0" | ||
msg: "Role FAILED idempotent test on CentOS6: {{centos6_changed|join('\n')}} tasks reported change on second run." | ||
|
||
- assert: | ||
that: | ||
- "play_output.stats.rhel6.changed == 0" | ||
msg: "Role FAILED idempotent test on RHEL6: {{rhel6_changed|join('\n')}} tasks reported change on second run." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[baseline_hosts] | ||
centos6 ansible_port=2200 ansible_ssh_private_key_file=.vagrant/machines/centos6-stig/virtualbox/private_key | ||
rhel6 ansible_port=2201 ansible_ssh_private_key_file=.vagrant/machines/rhel6-stig/virtualbox/private_key | ||
|
||
[baseline_hosts:vars] | ||
ansible_host=127.0.0.1 | ||
ansible_user=vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
- name: Setup hosts and apply STIG | ||
hosts: all | ||
become: yes | ||
|
||
tasks: | ||
- name: Register system with RedHat | ||
include_role: | ||
name: redhat-subscription | ||
when: ansible_distribution == 'RedHat' | ||
|
||
- name: Remove EPEL | ||
yum: | ||
name: epel-release | ||
state: absent | ||
|
||
- name: Apply STIG | ||
include_role: | ||
name: ../../RHEL6-STIG |