From 36eb18be8c54d415d8ca6b11f3de300df3da91e1 Mon Sep 17 00:00:00 2001 From: Anil Belur Date: Fri, 12 Dec 2025 00:26:37 +1000 Subject: [PATCH] Feat: Update python-install for Ubuntu 24.04 with Podman - Switch from Docker to Podman driver for molecule tests - Update GitHub workflow to install Podman and use requirements.txt - Add Ubuntu 24.04 (noble) to supported platforms - Create ansible.cfg with roles_path and deprecation settings - Add requirements.txt for molecule dependencies - Update molecule platforms to ubuntu2204 and ubuntu2404 - Set MOLECULE_PROJECT_DIRECTORY and ANSIBLE_ROLES_PATH in workflow - Add CentOS 9 and CentOS Stream 9 variable files Change-Id: Ie69de29bb2d1d6434b8b29ae775ad8c2e48c5391 Signed-off-by: Anil Belur --- .github/workflows/gerrit-verify.yaml | 18 +++++++++++------- ansible.cfg | 7 +++++++ meta/main.yml | 1 + molecule/default/molecule.yml | 23 +++++++++++++---------- requirements.txt | 4 ++++ tasks/main.yml | 9 +++++++++ vars/CentOS Stream-9.yml | 8 ++++++++ vars/CentOS-9.yml | 10 ++++++++++ 8 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 ansible.cfg create mode 100644 requirements.txt create mode 100644 vars/CentOS Stream-9.yml create mode 100644 vars/CentOS-9.yml diff --git a/.github/workflows/gerrit-verify.yaml b/.github/workflows/gerrit-verify.yaml index 040838b..2eae8b1 100644 --- a/.github/workflows/gerrit-verify.yaml +++ b/.github/workflows/gerrit-verify.yaml @@ -111,8 +111,8 @@ jobs: strategy: matrix: distro: - - ubuntu2004 - ubuntu2204 + - ubuntu2404 fail-fast: false steps: - name: Gerrit Checkout @@ -123,17 +123,21 @@ jobs: gerrit-project: ${{ inputs.GERRIT_PROJECT }} gerrit-url: ${{ vars.GERRIT_URL }} delay: "0s" - - name: Install test dependencies. + - name: Install Podman + run: | + sudo apt-get update + sudo apt-get install -y podman + - name: Install test dependencies run: | python -m pip install --upgrade pip - pip3 install ansible ansible-lint molecule-plugins[docker] docker - - name: Run Molecule tests. - run: molecule test - working-directory: ${{env.working-directory}} + pip3 install -r requirements.txt + - name: Run Molecule tests + run: molecule test --platform-name ${{ matrix.distro }} env: PY_COLORS: "1" ANSIBLE_FORCE_COLOR: "1" - MOLECULE_PLATFORM_NAME: ${{ matrix.distro }} + MOLECULE_PROJECT_DIRECTORY: "${{ github.workspace }}" + ANSIBLE_ROLES_PATH: "${{ github.workspace }}/.." vote: if: ${{ always() }} diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..7b146e2 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,7 @@ +[defaults] +roles_path = ..:~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles +deprecation_warnings = False +inject_facts_as_vars = False + +[privilege_escalation] +become = True diff --git a/meta/main.yml b/meta/main.yml index dc8de47..46e44cb 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -23,6 +23,7 @@ galaxy_info: - bionic - focal - jammy + - noble galaxy_tags: - pyenv diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 85a28a5..66ec485 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -2,14 +2,14 @@ dependency: name: galaxy driver: - name: docker + name: podman platforms: - # - name: centos7 - # image: centos:7 - # - name: centos8 - # image: quay.io/centos/centos:stream8 - # - name: ubuntu1804 - # image: ubuntu:18.04 + - name: centos7 + image: centos:7 + - name: centos8 + image: quay.io/centos/centos:stream8 + - name: ubuntu1804 + image: ubuntu:18.04 - name: ubuntu2004 image: ubuntu:20.04 - name: ubuntu2204 @@ -18,18 +18,21 @@ platforms: image: ubuntu:24.04 provisioner: name: ansible - # Fix for role path finding in latest molecule versions (~25.4.0) - env: - ANSIBLE_ROLES_PATH: ../../../ scenario: name: default test_sequence: + - dependency + - cleanup - destroy - dependency - syntax - create - prepare - converge + - idempotence - side_effect - verify + - cleanup - destroy +verifier: + name: testinfra diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..0ec030c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +ansible +ansible-lint +molecule +molecule-plugins[podman] diff --git a/tasks/main.yml b/tasks/main.yml index 99b1286..499ccf4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -12,6 +12,15 @@ name: '{{ python_packages }}' state: present +- name: Install virtualenv via pip on EL9 (broken RPM deps) + become: true + ansible.builtin.pip: + name: virtualenv + state: present + executable: pip3 + when: + - ansible_distribution == 'CentOS' and ansible_distribution_major_version | int >= 9 + - name: Set Python version on Ubuntu >= 18.04 or CentOS 7 ansible.builtin.set_fact: pyenv_cmd: "{{ python_versions | join(' ') }}" diff --git a/vars/CentOS Stream-9.yml b/vars/CentOS Stream-9.yml new file mode 100644 index 0000000..0e61a5b --- /dev/null +++ b/vars/CentOS Stream-9.yml @@ -0,0 +1,8 @@ +--- +python_packages_distro: + - libffi-devel + - python3 + - python3-devel + - python3-pip + - python3-setuptools + - python3-virtualenv diff --git a/vars/CentOS-9.yml b/vars/CentOS-9.yml new file mode 100644 index 0000000..a26d301 --- /dev/null +++ b/vars/CentOS-9.yml @@ -0,0 +1,10 @@ +--- +# CentOS Stream 9 uses Python 3.9+ as default +# No python36, python38, or openssl11 packages available +# python3-virtualenv from EPEL has broken deps; install via pip instead +python_packages_distro: + - libffi-devel + - python3 + - python3-devel + - python3-pip + - python3-setuptools -- 2.16.6