Skip to content

Commit

Permalink
Merge pull request #10 from kysrpex/molecule
Browse files Browse the repository at this point in the history
Add testing using Ansible Molecule
  • Loading branch information
hexylena authored Dec 11, 2023
2 parents c57dc47 + 5e6f807 commit f97de64
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/molecule-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ansible>=9.1.0,<10.0.0
ansible-core~=2.16
molecule>=6.0.2,<7.0.0
molecule-plugins[podman]>=23.5.0,<24.0.0
32 changes: 32 additions & 0 deletions .github/workflows/molecule.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Ansible Molecule

"on":
push:
branches:
- master
pull_request:

jobs:
molecule:
name: Molecule
runs-on: ubuntu-22.04
steps:
- name: Check out the codebase.
uses: actions/checkout@v4

- name: Setup Python.
uses: actions/setup-python@v4
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: .github/workflows/molecule-requirements.txt

- name: Install Ansible Molecule.
run: pip install --user -r .github/workflows/molecule-requirements.txt

- name: Run Ansible Molecule.
run: |
molecule --base-config molecule/base.yml test
env:
ANSIBLE_FORCE_COLOR: '1'
7 changes: 7 additions & 0 deletions molecule/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Ansible Molecule tests

Use the base configuration file when calling molecule, like this.

```shell
molecule --base-config molecule/base.yml test
```
36 changes: 36 additions & 0 deletions molecule/base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
dependency:
name: galaxy
driver:
name: podman
platforms:
- name: el-7
image: centos:7
- name: el-8
image: rockylinux:8
- name: el-9
image: rockylinux:9
- name: ubuntu-focal
image: ubuntu:focal
- name: ubuntu-jammy
image: ubuntu:jammy
- name: ubuntu-lunar
image: ubuntu:lunar
- name: ubuntu-mantic
image: ubuntu:mantic
provisioner:
name: ansible
config_options:
defaults:
interpreter_python: auto_silent
callback_whitelist: profile_tasks, timer, yaml
ssh_connection:
pipelining: true
inventory:
host_vars:
el-7:
ansible_python_interpreter: /usr/bin/python
el-8:
ansible_python_interpreter: /usr/bin/python3
verifier:
name: ansible
9 changes: 9 additions & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Converge
hosts: all
vars_files:
- vars.yml
tasks:
- name: "Include galaxyproject.gxadmin"
ansible.builtin.include_role:
name: "galaxyproject.gxadmin"
Empty file added molecule/default/molecule.yml
Empty file.
1 change: 1 addition & 0 deletions molecule/default/vars.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---

0 comments on commit f97de64

Please sign in to comment.