Skip to content

Commit

Permalink
Always use python3 during molecule testing
Browse files Browse the repository at this point in the history
Python2 went out of style more than a decade ago, and was "sunset"
over four years ago, 2020-01-01.

Sure CentOS might have some additional python2 support thanks to
RedHat, but you know what else it has? Python3. And with
epel-release, we get access to python3-PyMySQL, which allows us to
keep things simple.

The geerlingguy centos7 comes without python3, so we can either
drop it, or roll our own. This is the roll-your-own approach.

Grab the latest packaged molecule 4 release and the latest
molecule-docker straight from git. There's a fix that went in after
2.1.0 (cb1c1c31a4a468fb243fc2000656504a3ca00bb3) that fixes a bug
where the molecule.yml would get overwritten during image building.
  • Loading branch information
eb4x committed May 6, 2024
1 parent da85722 commit 3a091b1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 24 deletions.
52 changes: 34 additions & 18 deletions .github/workflows/proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,33 @@ jobs:
fail-fast: false
matrix:
container:
- rockylinux9
- rockylinux8
- centos7
- ubuntu2204
- ubuntu2004
- ubuntu1804
- debian12
- debian11
- debian10
- name: rockylinux9
base_image: rockylinux/rockylinux:9-ubi-init
os_family: redhat
- name: rockylinux8
base_image: rockylinux/rockylinux:8-ubi-init
os_family: redhat
- name: centos7
base_image: centos/systemd:latest
os_family: redhat
- name: ubuntu2204
base_image: ubuntu:22.04
os_family: debian
- name: ubuntu2004
base_image: ubuntu:20.04
os_family: debian
- name: ubuntu1804
base_image: ubuntu:18.04
os_family: debian
- name: debian12
base_image: debian:12
os_family: debian
- name: debian11
base_image: debian:11
os_family: debian
- name: debian10
base_image: debian:10
os_family: debian
collection_role:
- zabbix_proxy
database:
Expand All @@ -39,12 +57,11 @@ jobs:
- v64
- v62
- v60
include:
- interpreter: python3
- interpreter: python
container: centos7
exclude:
- container: debian12
- container:
name: debian12
base_image: debian:12
os_family: debian
version: v62
steps:
- name: Check out code
Expand Down Expand Up @@ -78,10 +95,9 @@ jobs:

- name: Run role tests
run: >-
MY_MOLECULE_CONTAINER=${{ matrix.container }}
MY_MOLECULE_IMAGE=${{ matrix.container }}
MY_MOLECULE_CONTAINER=${{ matrix.container.name }}
MY_MOLECULE_IMAGE=${{ matrix.container.base_image }}
MY_MOLECULE_OS_FAMILY=${{ matrix.container.os_family }}
MY_MOLECULE_VERSION=${{ matrix.version }}
MY_MOLECULE_DATABASE=${{ matrix.database }}
MY_MOLECULE_INTERPRETER=${{ matrix.interpreter }}
MY_MOLECULE_DOCKER_COMMAND=${{ matrix.command }}
molecule test -s ${{ matrix.collection_role }}
3 changes: 3 additions & 0 deletions molecule/zabbix_proxy/Dockerfile.debian.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM {{ item.base_image }}
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip systemd-sysv
CMD ["/sbin/init"]
3 changes: 3 additions & 0 deletions molecule/zabbix_proxy/Dockerfile.redhat.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM {{ item.base_image }}
RUN yum install -y python3-pip
CMD ["/sbin/init"]
11 changes: 5 additions & 6 deletions molecule/zabbix_proxy/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ driver:
name: docker
platforms:
- name: zabbix-proxy-${MY_MOLECULE_VERSION:-v64}-${MY_MOLECULE_DATABASE:-mysql}-${MY_MOLECULE_CONTAINER:-rockylinux8}
image: geerlingguy/docker-${MY_MOLECULE_IMAGE:-rockylinux8}-ansible:latest
dockerfile: Dockerfile.${MY_MOLECULE_OS_FAMILY:-redhat}.j2
base_image: ${MY_MOLECULE_IMAGE:-rockylinux/rockylinux:8-ubi-init}
image: ${MY_MOLECULE_CONTAINER:-rockylinux8}
privileged: true
pre_build_image: true
command: ${MOLECULE_DOCKER_COMMAND:-""}
command: /sbin/init
networks:
- name: zabbix
volumes:
Expand All @@ -22,10 +23,8 @@ provisioner:
ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles
inventory:
group_vars:
python3:
all:
ansible_python_interpreter: /usr/bin/python3
python:
ansible_python_interpreter: /usr/bin/python
v64:
zabbix_proxy_version: 6.4
v62:
Expand Down

0 comments on commit 3a091b1

Please sign in to comment.