From: Anil Belur Date: Thu, 11 Dec 2025 14:38:10 +0000 (+1000) Subject: Feat: Update docker-install for Ubuntu 24.04 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=6b24ed31861fe9c735f800335df112d7237197f3;p=ansible%2Froles%2Fdocker-install.git Feat: Update docker-install for Ubuntu 24.04 - 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 - Remove EOL Ubuntu 18.04, 20.04, CentOS 7 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 - Update tasks/main.yml to use ansible_facts dict syntax - Update meta dependencies to community.general 10.1.0 Change-Id: Iae76fbcc741f3f0d59bc56d7ab4517fad3210e58 Signed-off-by: Anil Belur --- diff --git a/.github/workflows/gerrit-verify.yaml b/.github/workflows/gerrit-verify.yaml index 040838b..72b5d68 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..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/meta/main.yml b/meta/main.yml index 02977b4..ade4dc0 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -8,23 +8,23 @@ galaxy_info: issue_tracker_url: https://jira.linuxfoundation.org license: MIT - min_ansible_version: 1.2 + min_ansible_version: "2.14" platforms: - name: EL versions: - - 7 - 8 - 9 - name: Ubuntu versions: - - bionic - - focal - jammy + - noble galaxy_tags: - containers - docker -dependencies: [] +dependencies: + - role: community.general + version: ">=10.1.0" diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml index 75348fb..f9f2094 100644 --- a/molecule/default/molecule.yml +++ b/molecule/default/molecule.yml @@ -2,55 +2,21 @@ dependency: name: galaxy driver: - name: docker + name: podman platforms: - - name: centos7 - image: centos:7 - groups: - - centos - - centos_version - - name: centos7-version - image: centos:7 - groups: - - centos - - centos_version - - name: centos8 - image: quay.io/centos/centos:stream8 - groups: - - centos - - centos_version - - name: centos9 - image: quay.io/centos/centos:stream9 - groups: - - centos - - centos_version - - name: ubuntu1804 - image: ubuntu:18.04 - - name: ubuntu1804-version - image: ubuntu:18.04 - groups: - - ubuntu_version - - name: ubuntu2004 - image: ubuntu:20.04 - - name: ubuntu2004-version - image: ubuntu:20.04 - groups: - - ubuntu_version - name: ubuntu2204 image: ubuntu:22.04 - - name: ubuntu2204-version - image: ubuntu:22.04 - groups: - - ubuntu_version + - name: ubuntu2404 + image: ubuntu:24.04 provisioner: name: ansible inventory: - group_vars: - centos_version: - centos_docker_version: 18.06.1.ce - ubuntu_version: - ubuntu_docker_version: 18.06.1~ce~3-0~ubuntu + 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/requirements.txt b/requirements.txt new file mode 100644 index 0000000..493fef7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +ansible>=2.14 +ansible-lint>=6.0 +molecule>=6.0 +molecule-plugins[podman]>=23.5.0 diff --git a/tasks/main.yml b/tasks/main.yml index 252ecd7..1a7478b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -2,30 +2,30 @@ - name: "Checking for x86_64" ansible.builtin.set_fact: host_arch: "amd64" - when: "'x86_64' in ansible_architecture" + when: "'x86_64' in ansible_facts['architecture']" - name: "Checking for aarch64" ansible.builtin.set_fact: host_arch: "arm64" - when: "'aarch64' in ansible_architecture" + when: "'aarch64' in ansible_facts['architecture']" - name: "Checking for Centos docker version" ansible.builtin.set_fact: docker_ce_name: 'docker-ce-{{ centos_docker_version }}' when: - - ansible_os_family == 'RedHat' + - ansible_facts['os_family'] == 'RedHat' - centos_docker_version != 'latest' - name: "Checking for Ubuntu docker version" ansible.builtin.set_fact: docker_ce_name: 'docker-ce={{ ubuntu_docker_version }}' when: - - ansible_distribution == 'Ubuntu' + - ansible_facts['distribution'] == 'Ubuntu' - ubuntu_docker_version != 'latest' - name: Install Docker (RedHat 7) become: true - when: ansible_os_family == 'RedHat' and ansible_distribution_major_version == "7" + when: ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == "7" block: - name: Install Docker requirements ansible.builtin.yum: @@ -46,7 +46,7 @@ - name: Install Docker (RedHat 8) become: true - when: ansible_os_family == 'RedHat' and ansible_distribution_major_version >= "8" + when: ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] >= "8" block: - name: Remove confliting packages with Docker-ce ansible.builtin.yum: @@ -80,7 +80,7 @@ - name: Install Docker (Ubuntu) become: true - when: ansible_distribution == 'Ubuntu' + when: ansible_facts['distribution'] == 'Ubuntu' block: - name: Install Docker requirements ansible.builtin.package: @@ -96,7 +96,7 @@ state: present - name: Add Docker apt-repository ansible.builtin.apt_repository: - repo: 'deb [arch={{ host_arch }}] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} {{ docker_repo_channel }}' + repo: 'deb [arch={{ host_arch }}] https://download.docker.com/linux/ubuntu {{ ansible_facts["distribution_release"] }} {{ docker_repo_channel }}' state: present - name: Install Docker CE ansible.builtin.package: @@ -139,7 +139,7 @@ path: /lib/systemd/system/docker.service regexp: '^ExecStart=' line: 'ExecStart=/usr/bin/dockerd' - when: ansible_distribution == 'Ubuntu' + when: ansible_facts['distribution'] == 'Ubuntu' become: true - name: Fix broken systemd file on Red Hat @@ -147,7 +147,7 @@ path: /usr/lib/systemd/system/docker.service regexp: '^ExecStart=' line: 'ExecStart=/usr/bin/dockerd' - when: ansible_os_family == 'RedHat' + when: ansible_facts['os_family'] == 'RedHat' become: true - name: Enable Docker service @@ -155,5 +155,5 @@ name: docker enabled: true ignore_errors: true - when: ansible_os_family == 'RedHat' + when: ansible_facts['os_family'] == 'RedHat' become: true