Skip to content

Commit

Permalink
add molecule tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsysmin committed Feb 1, 2024
1 parent d5d3844 commit 3a5c2dc
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 74 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: "ericsysmin.docker.docker"
on:
push:
paths:
- 'roles/docker/**'
- 'molecule/docker/**'
- '.github/workflows/docker.yml'
pull_request:
paths:
- 'roles/docker/**'
- 'molecule/docker/**'
- '.github/workflows/docker.yml'
jobs:
molecule:
runs-on: ubuntu-latest
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:
- docker
steps:
- name: Check out code
uses: actions/checkout@v1
with:
path: ansible_collections/ericsysmin/docker

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install dependencies
run: |
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
python -m pip install --upgrade pip
pip install ansible molecule yamllint ansible-lint molecule-plugins[docker]
- name: Run role tests
run: >-
molecule --version &&
ansible --version &&
MOLECULE_COMMAND=${{ matrix.molecule_distro.command }}
MOLECULE_DISTRO=${{ matrix.molecule_distro.distro }}
molecule --debug test -s ${{ matrix.collection_role }}
6 changes: 0 additions & 6 deletions molecule/default/.ansible-lint

This file was deleted.

11 changes: 0 additions & 11 deletions molecule/default/.yamllint

This file was deleted.

30 changes: 0 additions & 30 deletions molecule/default/Dockerfile.j2

This file was deleted.

22 changes: 0 additions & 22 deletions molecule/default/converge.yml

This file was deleted.

2 changes: 0 additions & 2 deletions molecule/default/files/override.conf

This file was deleted.

1 change: 1 addition & 0 deletions molecule/docker/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ lookup('url', 'https://raw.githubusercontent.com/ericsysmin/ansible-molecule-dockerfiles/main/' ~ item.image ~ '/Dockerfile', split_lines=False) }}
26 changes: 26 additions & 0 deletions molecule/docker/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: Converge
hosts: all
pre_tasks:
- name: Wait for systemd to complete initialization. # noqa command-instead-of-module
ansible.builtin.command: systemctl is-system-running
register: systemctl_status
until: >-
"running" in systemctl_status.stdout or "degraded" in
systemctl_status.stdout
retries: 30
delay: 5
when:
- ansible_service_mgr == "systemd"
- ansible_distribution == "Fedora"
changed_when: false
- name: Update package cache
ansible.builtin.package:
update_cache: true
changed_when: false
register: task_result
until: task_result is success
retries: 10
delay: 2
roles:
- role: ericsysmin.docker.docker
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ lint: |
ansible-lint
platforms:
- name: instance
image: ${MOLECULE_DISTRO:-ubuntu:xenial}
image: ${MOLECULE_DISTRO:-ubuntu-xenial}
privileged: true
service_manager: ${MOLECULE_SERVICE_MANAGER:-systemd}
command: ${MOLECULE_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
command: ${MOLECULE_COMMAND:-""}
provisioner:
name: ansible
playbooks:
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 3a5c2dc

Please sign in to comment.