-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Molecule tests for atomic-red-team role.
**Added:** - Molecule configuration - Created new `molecule` configuration files for the `atomic-red-team` role to support local testing and verification. - Converge playbook - Added `converge.yml` playbook for applying the role during testing. - Inventory file - Created an inventory file for Molecule testing. - Docker platforms - Defined Docker platforms in `molecule.yml` for testing the role on Ubuntu, Kali, and Rocky Linux containers. - Verify playbook - Added `verify.yml` playbook for verifying the role's functionality during testing.
- Loading branch information
Showing
4 changed files
with
89 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
- name: Converge | ||
hosts: all | ||
tasks: | ||
- name: Include default variables | ||
ansible.builtin.include_vars: | ||
file: "../../defaults/main.yml" | ||
- name: Include variables | ||
ansible.builtin.include_vars: | ||
file: "../../vars/main.yml" | ||
roles: | ||
- name: Run the atomic-red-team role | ||
role: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" |
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 @@ | ||
localhost |
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,41 @@ | ||
--- | ||
# Run molecule inside of a docker container | ||
driver: | ||
name: docker | ||
|
||
platforms: | ||
- name: ubuntu-atomic-red-team | ||
image: "geerlingguy/docker-ubuntu2204-ansible:latest" | ||
# Setting the command to this is necessary for systemd containers | ||
command: "" | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:rw | ||
cgroupns_mode: host | ||
privileged: true | ||
|
||
- name: kali-atomic-red-team | ||
image: cisagov/docker-kali-ansible:latest | ||
# Setting the command to this is necessary for systemd containers | ||
command: "" | ||
pre_build_image: true | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:rw | ||
cgroupns_mode: host | ||
privileged: true | ||
|
||
- name: redhat-atomic-red-team | ||
image: "geerlingguy/docker-rockylinux9-ansible:latest" | ||
# Setting the command to this is necessary for systemd containers | ||
command: "" | ||
volumes: | ||
- /sys/fs/cgroup:/sys/fs/cgroup:rw | ||
cgroupns_mode: host | ||
privileged: true | ||
|
||
provisioner: | ||
name: ansible | ||
playbooks: | ||
converge: ${MOLECULE_PLAYBOOK:-converge.yml} | ||
|
||
verifier: | ||
name: ansible |
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: Verify | ||
hosts: all | ||
gather_facts: true | ||
tasks: | ||
- name: Include default variables | ||
ansible.builtin.include_vars: | ||
file: "../../defaults/main.yml" | ||
|
||
- name: Include variables | ||
ansible.builtin.include_vars: | ||
file: "../../vars/main.yml" | ||
|
||
- name: Check if PowerShell is installed | ||
ansible.builtin.shell: | ||
cmd: "pwsh -NoProfile -v" | ||
register: pwsh_version | ||
ignore_errors: true | ||
|
||
- name: Assert that PowerShell is installed | ||
ansible.builtin.assert: | ||
that: | ||
- pwsh_version.rc == 0 | ||
- "'PowerShell' in pwsh_version.stdout" | ||
|
||
- name: Check if /usr/local/bin is in $PATH | ||
ansible.builtin.shell: | ||
cmd: "echo $PATH" | ||
register: system_path | ||
|
||
- name: Assert that /usr/local/bin is in $PATH | ||
ansible.builtin.assert: | ||
that: | ||
- "'/usr/local/bin' in system_path.stdout" |