From 8d0121372916091d060e0bccedd33d29d22b5bf3 Mon Sep 17 00:00:00 2001 From: Anil Belur Date: Sat, 13 Dec 2025 12:17:49 +1000 Subject: [PATCH] Fix: Update to Ubuntu 24.04 and Podman driver - Update molecule platforms to Ubuntu 22.04, 24.04 - Remove EOL distributions (CentOS 7, Ubuntu 18.04, 20.04) - NOTE: CentOS Stream 9 not included - Mono project does not yet support EL9 - Switch from Docker to Podman driver - Add ansible.cfg with role path and deprecation settings - Add requirements.txt with Podman molecule plugin - Update GitHub workflow to use Podman and Python 3.11 - Add MOLECULE_PROJECT_DIRECTORY and ANSIBLE_ROLES_PATH env vars - Modernize prepare.yml with ansible.builtin FQCN - Set inject_facts_as_vars: false to fix deprecation warning - Update tasks to use ansible_facts dictionary - Handle Ubuntu 24.04 nuget package unavailability - Handle CentOS 9 mono repository limitations with warnings Change-Id: Ie166b04101e7f7b0f4a90c358174672bca9bd7bc Signed-off-by: Anil Belur --- .github/workflows/gerrit-verify.yaml | 17 ++++++++++------- ansible.cfg | 7 +++++++ molecule/default/converge.yml | 1 + molecule/default/molecule.yml | 23 +++++++++++++++-------- molecule/default/prepare.yml | 19 +++++++++---------- requirements.txt | 4 ++++ tasks/Debian.yml | 12 +++++++++++- tasks/RedHat.yml | 30 ++++++++++++++++++++++++++---- tasks/main.yml | 4 ++-- 9 files changed, 85 insertions(+), 32 deletions(-) create mode 100644 ansible.cfg create mode 100644 requirements.txt diff --git a/.github/workflows/gerrit-verify.yaml b/.github/workflows/gerrit-verify.yaml index 040838b..bc6366c 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,20 @@ jobs: gerrit-project: ${{ inputs.GERRIT_PROJECT }} gerrit-url: ${{ vars.GERRIT_URL }} delay: "0s" - - name: Install test dependencies. - run: | - python -m pip install --upgrade pip - pip3 install ansible ansible-lint molecule-plugins[docker] docker - - name: Run Molecule tests. + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - name: Install test dependencies + run: pip3 install -r requirements.txt + - name: Run Molecule tests run: molecule test - working-directory: ${{env.working-directory}} 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..b49fcc8 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,7 @@ +[defaults] +roles_path = ./ +deprecation_warnings = False +inject_facts_as_vars = False + +[privilege_escalation] +become = True diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 1e30adc..a8044fd 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -1,5 +1,6 @@ --- - name: Converge hosts: all + gather_facts: true roles: - role: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 23a56f1..4260246 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -2,19 +2,26 @@ dependency: name: galaxy driver: - name: docker + name: podman platforms: - - name: centos7 - image: centos:7 - - name: ubuntu1804 - image: ubuntu:18.04 - - name: ubuntu2004 - image: ubuntu:20.04 - name: ubuntu2204 image: ubuntu:22.04 + pre_build_image: false + - name: ubuntu2404 + image: ubuntu:24.04 + pre_build_image: false provisioner: name: ansible + config_options: + defaults: + inject_facts_as_vars: false + inventory: + host_vars: + ubuntu2204: + ansible_python_interpreter: /usr/bin/python3 + ubuntu2404: + ansible_python_interpreter: /usr/bin/python3 scenario: name: default verifier: - name: testinfra + name: ansible diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml index 0ae381f..719551d 100644 --- a/molecule/default/prepare.yml +++ b/molecule/default/prepare.yml @@ -2,25 +2,24 @@ - name: Prepare hosts: all gather_facts: true - tasks: - name: Update APT cache - apt: - update_cache: yes - when: ansible_distribution == 'Ubuntu' + ansible.builtin.apt: + update_cache: true + when: ansible_facts['distribution'] == 'Ubuntu' become: true - - name: Install cron - yum: + - name: Install cron on RedHat + ansible.builtin.dnf: name: cronie state: present - when: ansible_os_family == 'RedHat' + when: ansible_facts['os_family'] == 'RedHat' become: true - - name: Install packages - package: + - name: Install required packages + ansible.builtin.package: name: - zip - unzip state: present - become: yes + become: true diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..b6bd94c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +ansible>=2.10 +ansible-lint>=6.0.0 +molecule>=6.0.0 +molecule-plugins[podman]>=23.0.0 diff --git a/tasks/Debian.yml b/tasks/Debian.yml index 439caf3..40a2781 100644 --- a/tasks/Debian.yml +++ b/tasks/Debian.yml @@ -3,7 +3,17 @@ ansible.builtin.package: name: - mono-complete - - nuget + - "{{ 'nuget' if ansible_facts.distribution_version is version('24.04', '<') else omit }}" state: present update_cache: true become: true + when: ansible_facts.distribution_version is version('24.04', '<') + +- name: Install mono-complete only (Ubuntu 24.04+) + ansible.builtin.package: + name: + - mono-complete + state: present + update_cache: true + become: true + when: ansible_facts.distribution_version is version('24.04', '>=') diff --git a/tasks/RedHat.yml b/tasks/RedHat.yml index 74606c3..b3d07b4 100644 --- a/tasks/RedHat.yml +++ b/tasks/RedHat.yml @@ -1,25 +1,47 @@ --- -- name: Add Mono RPM Key +- name: Add Mono RPM Key (CentOS <= 8) ansible.builtin.rpm_key: key: http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF state: present become: true + when: ansible_facts.distribution_major_version is version('9', '<') + ignore_errors: true - name: Add Mono repository ansible.builtin.yum_repository: name: mono-project description: Mono Project CentOS repository - baseurl: http://download.mono-project.com/repo/centos + baseurl: http://download.mono-project.com/repo/centos{{ ansible_facts.distribution_major_version }} enabled: true + gpgcheck: false repo_gpgcheck: false skip_if_unavailable: true become: true -- name: Install mono-complete and nuget - ansible.builtin.yum: +- name: Install mono-complete and nuget (CentOS <= 8) + ansible.builtin.dnf: name: - mono-complete - nuget state: present update_cache: true become: true + when: ansible_facts.distribution_major_version is version('9', '<') + +- name: Install mono-complete only (CentOS 9+) + ansible.builtin.dnf: + name: + - mono-complete + state: present + update_cache: true + become: true + when: ansible_facts.distribution_major_version is version('9', '>=') + ignore_errors: true + register: mono_install_centos9 + +- name: Warn about Mono availability on CentOS 9+ + ansible.builtin.debug: + msg: "WARNING: Mono may not be available for CentOS Stream 9. Mono project may not have official support yet." + when: + - ansible_facts.distribution_major_version is version('9', '>=') + - mono_install_centos9 is failed diff --git a/tasks/main.yml b/tasks/main.yml index cfcd808..337148b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,5 @@ --- -- name: Include tasks from '{{ ansible_os_family }}' +- name: Include tasks from '{{ ansible_facts.os_family }}' ansible.builtin.include_tasks: '{{ item }}' with_first_found: - - '{{ ansible_os_family }}.yml' + - '{{ ansible_facts.os_family }}.yml' -- 2.16.6