Skip to content

Commit

Permalink
Merge pull request #85 from CoffeeITWorks/develop
Browse files Browse the repository at this point in the history
fixes powertools and molecule tests
  • Loading branch information
pablodav authored Jun 19, 2022
2 parents fd2a964 + 092d098 commit acd5d2c
Show file tree
Hide file tree
Showing 27 changed files with 163 additions and 128 deletions.
50 changes: 29 additions & 21 deletions .github/workflows/molecule-test.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# https://thedatabaseme.de/2022/01/17/automated-testing-your-ansible-role-with-molecule-and-github-actions/

name: Molecule pipeline test

on:
Expand Down Expand Up @@ -25,34 +27,40 @@ jobs:
uses: actions/checkout@v2
with:
path: "${{ github.repository }}"

- name: Molecule converge
uses: gofrolist/molecule-action@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
molecule_options: --debug --base-config molecule/_shared/base.yml
molecule_command: converge
# Always specify scenario and don't use default for better different use cases
molecule_args: --scenario-name ${{ matrix.scenario }}
python-version: '3.x'

- name: Install dependencies.
run: |
python3 -m pip install --upgrade pip
python3 -m pip install yamllint ansible-lint ansible "molecule[lint,docker]"
- name: Install Galaxy dependencies.
run: ansible-galaxy collection install community.docker

- name: check molecule version
run: molecule --version

- name: Run molecule converge
run: "molecule converge --scenario-name ${{ matrix.scenario }}"
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
- name: Molecule syntax
uses: gofrolist/molecule-action@v2
with:
molecule_options: --debug --base-config molecule/_shared/base.yml
molecule_command: syntax
# Always specify scenario and don't use default for better different use cases
molecule_args: --scenario-name ${{ matrix.scenario }}
working-directory: "${{ github.repository }}"

- name: Run molecule syntax
run: "molecule syntax --scenario-name ${{ matrix.scenario }}"
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
- name: Molecule idempotence
uses: gofrolist/molecule-action@v2
with:
molecule_options: --debug --base-config molecule/_shared/base.yml
molecule_command: idempotence
# Always specify scenario and don't use default for better different use cases
molecule_args: --scenario-name ${{ matrix.scenario }}
working-directory: "${{ github.repository }}"

- name: Run molecule idempotence
run: "molecule idempotence --scenario-name ${{ matrix.scenario }}"
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
working-directory: "${{ github.repository }}"
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.5.0
=====
* Fixes for molecule v4 tests
* Hotfix/81 enable power tools repo

2.4.6
=====
* win64 not supported anymore
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ ansible-playbook -i inventory/ roles.burp2_servers.yml -v -u pablo --ask-pass

Later you will be able to customize some vars adding your own values in `group_vars` variables or `host_vars`.

Requirements
------------

Install this role if you wanna use it with centos > 8
```yaml
- src: https://github.com/robertdebock/ansible-role-powertools
name: ansible-role-powertools
```

Role Name
---------

Expand Down
2 changes: 1 addition & 1 deletion ansible.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ roles_path = ../:/etc/ansible/roles:~/.ansible/roles
host_key_checking = False

retry_files_enabled = False
callback_whitelist = profile_tasks
callbacks_enabled = profile_tasks

[ssh_connection]
pipelining = False
4 changes: 4 additions & 0 deletions dev_requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# from GitHub, overriding the name and specifying a specific tag

- src: https://github.com/robertdebock/ansible-role-powertools
name: ansible-role-powertools
5 changes: 3 additions & 2 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
galaxy_info:
author: "Diego Daguerre / Pablo Estigarribia"
role_name: ansible_burp2_server
author: "coffeeitworks"
company: coffeeITWorks
description: ansible role to deploy and maintain burp backup

Expand All @@ -17,7 +18,7 @@ galaxy_info:
# - CC-BY
license: MIT

min_ansible_version: 2.0
min_ansible_version: 3.0

# Optionally specify the branch Galaxy will use when accessing the GitHub
# repo for this role. During role install, if no tags are available,
Expand Down
6 changes: 4 additions & 2 deletions molecule/centos-8/converge.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
- name: Converge
hosts: all
roles:
- role: ansible_burp2_server
tasks:
- name: Include ansible_burp2_server
include_role:
name: ansible_burp2_server
6 changes: 3 additions & 3 deletions molecule/centos-8/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ driver:
platforms:

- name: ansible_burp2_server-04
image: "geerlingguy/docker-centos8-ansible"
privileged: True
image: "docker.io/geerlingguy/docker-centos8-ansible"
#privileged: True
command: /sbin/init
pre_build_image: true
capabilities:
Expand All @@ -27,7 +27,7 @@ provisioner:
name: ansible
config_options:
defaults:
callback_whitelist: profile_tasks
callbacks_enabled: profile_tasks
ssh_connection:
pipelining: true
ssh_args: -o ControlMaster=auto -o ControlPersist=60s
Expand Down
14 changes: 0 additions & 14 deletions molecule/centos-8/tests/test_default.py

This file was deleted.

Binary file removed molecule/centos-8/tests/test_default.pyc
Binary file not shown.
6 changes: 4 additions & 2 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
- name: Converge
hosts: all
roles:
- role: ansible_burp2_server
tasks:
- name: Include ansible_burp2_server
include_role:
name: ansible_burp2_server
6 changes: 3 additions & 3 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ driver:
platforms:

- name: ansible_burp2_server-01
image: "geerlingguy/docker-ubuntu2004-ansible:latest"
image: "docker.io/geerlingguy/docker-ubuntu2004-ansible:latest"
#privileged: True
command: /sbin/init
pre_build_image: true
Expand All @@ -24,7 +24,7 @@ platforms:
- group1

- name: ansible_burp2_server-04
image: "geerlingguy/docker-centos8-ansible"
image: "docker.io/geerlingguy/docker-centos8-ansible"
#privileged: True
command: /sbin/init
pre_build_image: true
Expand All @@ -42,7 +42,7 @@ provisioner:
name: ansible
config_options:
defaults:
callback_whitelist: profile_tasks
callbacks_enabled: profile_tasks
ssh_connection:
pipelining: true
ssh_args: -o ControlMaster=auto -o ControlPersist=60s
Expand Down
14 changes: 0 additions & 14 deletions molecule/default/tests/test_default.py

This file was deleted.

Binary file removed molecule/default/tests/test_default.pyc
Binary file not shown.
6 changes: 4 additions & 2 deletions molecule/local/converge.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
- name: Converge
hosts: all
roles:
- role: ansible_burp2_server
tasks:
- name: Include ansible_burp2_server
include_role:
name: ansible_burp2_server
22 changes: 5 additions & 17 deletions molecule/local/molecule.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
# https://www.ansible.com/blog/developing-and-testing-ansible-roles-with-molecule-and-podman-part-1
# sudo setsebool -P container_manage_cgroup 1
dependency:
name: galaxy
options:
Expand All @@ -10,7 +12,7 @@ driver:
platforms:

- name: ansible_burp2_server-01
image: "geerlingguy/docker-ubuntu2004-ansible:latest"
image: "docker.io/geerlingguy/docker-ubuntu2004-ansible:latest"
#privileged: True
command: "/lib/systemd/systemd"
pre_build_image: true
Expand All @@ -24,26 +26,12 @@ platforms:
groups:
- group1

- name: ansible_burp2_server-04
image: "geerlingguy/docker-centos8-ansible"
command: /usr/sbin/init
#privileged: True
pre_build_image: true
capabilities:
- SYS_ADMIN
tmpfs:
- /run
- /tmp
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:ro"
groups:
- use_pip_package

provisioner:
name: ansible
config_options:
defaults:
callback_whitelist: profile_tasks
callbacks_enabled: profile_tasks, timer, yaml
interpreter_python: auto_silent
ssh_connection:
pipelining: false
ssh_args: -o ControlMaster=auto -o ControlPersist=60s
Expand Down
7 changes: 7 additions & 0 deletions molecule/local_centos8/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
- name: Converge
hosts: all
tasks:
- name: Include ansible_burp2_server
include_role:
name: ansible_burp2_server
43 changes: 43 additions & 0 deletions molecule/local_centos8/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
# https://www.ansible.com/blog/developing-and-testing-ansible-roles-with-molecule-and-podman-part-1
# sudo setsebool -P container_manage_cgroup 1
dependency:
name: galaxy
options:
ignore-certs: True
ignore-errors: True
role-file: dev_requirements.yml # this file is at the root of the git project same place as molecule is executed
driver:
name: podman
platforms:

- name: ansible_burp2_server-04
image: "docker.io/geerlingguy/docker-centos8-ansible"
command: /usr/sbin/init
#privileged: True
pre_build_image: true
capabilities:
- SYS_ADMIN
tmpfs:
- /run
- /tmp
volumes:
- "/sys/fs/cgroup:/sys/fs/cgroup:ro"
groups:
- use_pip_package

provisioner:
name: ansible
config_options:
defaults:
callbacks_enabled: profile_tasks, timer, yaml
interpreter_python: auto_silent
ssh_connection:
pipelining: false
ssh_args: -o ControlMaster=auto -o ControlPersist=60s
inventory:
group_vars:
master:
burpsrcext: "zip"
burp_version: "master"
burp_server_port_per_operation_bool: true
9 changes: 9 additions & 0 deletions molecule/local_centos8/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# This is an example playbook to execute Ansible tests.

- name: Verify
hosts: all
tasks:
- name: Example assertion
assert:
that: true
6 changes: 4 additions & 2 deletions molecule/ubuntu-2004/converge.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
- name: Converge
hosts: all
roles:
- role: ansible_burp2_server
tasks:
- name: Include ansible_burp2_server
include_role:
name: ansible_burp2_server
6 changes: 4 additions & 2 deletions molecule/ubuntu-2004/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ driver:
platforms:

- name: ansible_burp2_server-01
image: "geerlingguy/docker-ubuntu2004-ansible:latest"
image: "docker.io/geerlingguy/docker-ubuntu2004-ansible:latest"
privileged: True
command: /sbin/init
pre_build_image: true
Expand All @@ -27,7 +27,7 @@ provisioner:
name: ansible
config_options:
defaults:
callback_whitelist: profile_tasks
callbacks_enabled: profile_tasks
ssh_connection:
pipelining: true
ssh_args: -o ControlMaster=auto -o ControlPersist=60s
Expand All @@ -43,3 +43,5 @@ provisioner:
host_vars:
ansible_burp2_server-02:
burp_sv_server_user: 'burp'
verifier:
name: ansible
14 changes: 0 additions & 14 deletions molecule/ubuntu-2004/tests/test_default.py

This file was deleted.

Binary file removed molecule/ubuntu-2004/tests/test_default.pyc
Binary file not shown.
4 changes: 0 additions & 4 deletions requirements.yml

This file was deleted.

2 changes: 1 addition & 1 deletion tasks/1_1_multi_os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
- "../vars/{{ ansible_os_family }}.yml"
- "../vars/defaults.yml"

- include: 1_2_redhat.yml
- import_tasks: 1_2_redhat.yml
when: ansible_os_family == "RedHat"
Loading

0 comments on commit acd5d2c

Please sign in to comment.