Skip to content

Instantly share code, notes, and snippets.

@BradleyBoutcher
Created September 25, 2020 15:38
Show Gist options
  • Save BradleyBoutcher/a18b94f1b7322bd0a7fb04f7c6be5cff to your computer and use it in GitHub Desktop.
Save BradleyBoutcher/a18b94f1b7322bd0a7fb04f7c6be5cff to your computer and use it in GitHub Desktop.
Ansible Molecule example for Conjur Host Identity
name: "cyberark.conjur"
on:
push:
paths:
- 'roles/conjur_host_identity/**'
- 'molecule/conjur_host_identity/**'
- '.github/workflows/molecule-test.yml'
- 'molecule/common/**'
pull_request:
paths:
- 'roles/conjur_host_identity/**'
- 'molecule/conjur_host_identity/**'
- '.github/workflows/molecule-test.yml'
- 'molecule/common/**'
jobs:
molecule:
runs-on: ubuntu-18.04
env:
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
strategy:
fail-fast: true
matrix:
molecule_distro:
- { "distro":"centos-7", "command":"/usr/sbin/init" }
- { "distro":"centos-8", "command":"/usr/sbin/init" }
- { "distro":"fedora-32", "command":"/usr/sbin/init" }
- { "distro":"fedora-31", "command":"/usr/sbin/init" }
- { "distro":"fedora-30", "command":"/usr/lib/systemd/systemd" }
- { "distro":"ubuntu-16.04", "command":"/sbin/init" }
- { "distro":"ubuntu-18.04", "command":"/lib/systemd/systemd" }
- { "distro":"ubuntu-20.04", "command":"/lib/systemd/systemd" }
- { "distro":"debian-9", "command":"/lib/systemd/systemd" }
- { "distro":"debian-10", "command":"/lib/systemd/systemd" }
collection_role:
- conjur_host_identity
steps:
- name: Check out code
uses: actions/checkout@v1
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: |
sudo apt install docker
python -m pip install --upgrade pip
pip install git+https://github.com/ericsysmin/molecule.git@patch-2
pip install molecule yamllint ansible-lint docker
- name: Build the collection
run: |
collection_file=$( basename $(ansible-galaxy collection build -f | awk -F" " '{print $NF}'))
echo "::set-env name=COLLECTION_FILE::$collection_file"
- name: Install the collection
run: ansible-galaxy collection install $COLLECTION_FILE
- name: Run role test
run: >-
molecule --version &&
ansible --version &&
MOLECULE_COMMAND=${{ matrix.molecule_distro.command }}
MOLECULE_DISTRO=${{ matrix.molecule_distro.distro }}
molecule --debug test -s ${{ matrix.collection_role }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment