From 974398e36899e27efc7e12297c123c1c15bd6cc7 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Mon, 5 Aug 2024 10:23:33 -0700 Subject: [PATCH 01/12] Refactor to native jobs --- molecule/containerd/create.yml | 19 +++++ molecule/containerd/molecule.yml | 36 +++------- molecule/containerd/prepare.yml | 33 --------- molecule/docker/create.yml | 19 +++++ molecule/docker/group_vars/all/molecule.yml | 2 +- molecule/docker/molecule.yml | 39 ++++------ molecule/docker/prepare.yml | 33 --------- molecule/forget-package/create.yml | 19 +++++ molecule/forget-package/molecule.yml | 36 +++------- molecule/forget-package/prepare.yml | 16 ----- molecule/nerdctl/create.yml | 19 +++++ molecule/nerdctl/molecule.yml | 34 +++------ tox.ini | 33 +++++++++ .../playbooks/molecule/pre.yml | 22 ++---- zuul.d/playbooks/molecule/run.yml | 18 +++++ zuul.d/project.yaml | 71 +++++++++++++++++++ 16 files changed, 246 insertions(+), 203 deletions(-) create mode 100644 molecule/containerd/create.yml delete mode 100644 molecule/containerd/prepare.yml create mode 100644 molecule/docker/create.yml delete mode 100644 molecule/docker/prepare.yml create mode 100644 molecule/forget-package/create.yml create mode 100644 molecule/nerdctl/create.yml create mode 100644 tox.ini rename molecule/nerdctl/prepare.yml => zuul.d/playbooks/molecule/pre.yml (53%) create mode 100644 zuul.d/playbooks/molecule/run.yml diff --git a/molecule/containerd/create.yml b/molecule/containerd/create.yml new file mode 100644 index 0000000..267c81d --- /dev/null +++ b/molecule/containerd/create.yml @@ -0,0 +1,19 @@ +# Copyright (c) 2024 VEXXHOST, Inc. +# SPDX-License-Identifier: Apache-2.0 + +- name: Wait for user to read warning + hosts: localhost + tasks: + - name: Wait for user to read warning + ignore_errors: true # noqa: ignore-errors + ansible.builtin.fail: + msg: >- + ⚠️ + This code will make substantial changes to your machine, it is strongly + recommended that you run this on a server or virtual machine that you + dedicate to this purpose. + ⚠️ + + - name: Wait for user to read warning + ansible.builtin.wait_for: + timeout: 15 diff --git a/molecule/containerd/molecule.yml b/molecule/containerd/molecule.yml index bd2d1b1..1383dbd 100644 --- a/molecule/containerd/molecule.yml +++ b/molecule/containerd/molecule.yml @@ -1,39 +1,23 @@ -# Copyright (c) 2023 VEXXHOST, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. +# Copyright (c) 2024 VEXXHOST, Inc. +# SPDX-License-Identifier: Apache-2.0 dependency: name: galaxy driver: - name: docker + name: default + options: + managed: False + ansible_connection_options: + ansible_become: "true" + ansible_connection: local platforms: - name: instance - image: geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest - command: ${MOLECULE_DOCKER_COMMAND:-""} - privileged: true - cgroupns_mode: host - pre_build_image: true - environment: - container: docker - security_opts: - - apparmor=unconfined - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:rw - - /lib/modules:/lib/modules:ro provisioner: name: ansible config_options: connection: pipelining: true + defaults: + callbacks_enabled: ansible.posix.profile_tasks verifier: name: ansible diff --git a/molecule/containerd/prepare.yml b/molecule/containerd/prepare.yml deleted file mode 100644 index f144066..0000000 --- a/molecule/containerd/prepare.yml +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (c) 2023 VEXXHOST, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -- name: Prepare - hosts: all - become: true - pre_tasks: - - name: Wait for systemd to complete initialization - 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 - changed_when: false - failed_when: systemctl_status.rc > 1 - tasks: - - name: Run APT update - ansible.builtin.apt: - update_cache: yes - when: ansible_facts['pkg_mgr'] == "apt" diff --git a/molecule/docker/create.yml b/molecule/docker/create.yml new file mode 100644 index 0000000..267c81d --- /dev/null +++ b/molecule/docker/create.yml @@ -0,0 +1,19 @@ +# Copyright (c) 2024 VEXXHOST, Inc. +# SPDX-License-Identifier: Apache-2.0 + +- name: Wait for user to read warning + hosts: localhost + tasks: + - name: Wait for user to read warning + ignore_errors: true # noqa: ignore-errors + ansible.builtin.fail: + msg: >- + ⚠️ + This code will make substantial changes to your machine, it is strongly + recommended that you run this on a server or virtual machine that you + dedicate to this purpose. + ⚠️ + + - name: Wait for user to read warning + ansible.builtin.wait_for: + timeout: 15 diff --git a/molecule/docker/group_vars/all/molecule.yml b/molecule/docker/group_vars/all/molecule.yml index a5b24f3..5099a2c 100644 --- a/molecule/docker/group_vars/all/molecule.yml +++ b/molecule/docker/group_vars/all/molecule.yml @@ -1 +1 @@ -docker_version: 24.0.7 +docker_version: 24.0.9 diff --git a/molecule/docker/molecule.yml b/molecule/docker/molecule.yml index bd2d1b1..acaa088 100644 --- a/molecule/docker/molecule.yml +++ b/molecule/docker/molecule.yml @@ -1,39 +1,26 @@ -# Copyright (c) 2023 VEXXHOST, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. +# Copyright (c) 2024 VEXXHOST, Inc. +# SPDX-License-Identifier: Apache-2.0 dependency: name: galaxy driver: - name: docker + name: default + options: + managed: False + ansible_connection_options: + ansible_become: "true" + ansible_connection: local platforms: - name: instance - image: geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest - command: ${MOLECULE_DOCKER_COMMAND:-""} - privileged: true - cgroupns_mode: host - pre_build_image: true - environment: - container: docker - security_opts: - - apparmor=unconfined - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:rw - - /lib/modules:/lib/modules:ro provisioner: name: ansible config_options: connection: pipelining: true + defaults: + callbacks_enabled: ansible.posix.profile_tasks + inventory: + links: + group_vars: "${MOLECULE_SCENARIO_DIRECTORY}/group_vars" verifier: name: ansible diff --git a/molecule/docker/prepare.yml b/molecule/docker/prepare.yml deleted file mode 100644 index f144066..0000000 --- a/molecule/docker/prepare.yml +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (c) 2023 VEXXHOST, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -- name: Prepare - hosts: all - become: true - pre_tasks: - - name: Wait for systemd to complete initialization - 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 - changed_when: false - failed_when: systemctl_status.rc > 1 - tasks: - - name: Run APT update - ansible.builtin.apt: - update_cache: yes - when: ansible_facts['pkg_mgr'] == "apt" diff --git a/molecule/forget-package/create.yml b/molecule/forget-package/create.yml new file mode 100644 index 0000000..267c81d --- /dev/null +++ b/molecule/forget-package/create.yml @@ -0,0 +1,19 @@ +# Copyright (c) 2024 VEXXHOST, Inc. +# SPDX-License-Identifier: Apache-2.0 + +- name: Wait for user to read warning + hosts: localhost + tasks: + - name: Wait for user to read warning + ignore_errors: true # noqa: ignore-errors + ansible.builtin.fail: + msg: >- + ⚠️ + This code will make substantial changes to your machine, it is strongly + recommended that you run this on a server or virtual machine that you + dedicate to this purpose. + ⚠️ + + - name: Wait for user to read warning + ansible.builtin.wait_for: + timeout: 15 diff --git a/molecule/forget-package/molecule.yml b/molecule/forget-package/molecule.yml index bd2d1b1..1383dbd 100644 --- a/molecule/forget-package/molecule.yml +++ b/molecule/forget-package/molecule.yml @@ -1,39 +1,23 @@ -# Copyright (c) 2023 VEXXHOST, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. +# Copyright (c) 2024 VEXXHOST, Inc. +# SPDX-License-Identifier: Apache-2.0 dependency: name: galaxy driver: - name: docker + name: default + options: + managed: False + ansible_connection_options: + ansible_become: "true" + ansible_connection: local platforms: - name: instance - image: geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest - command: ${MOLECULE_DOCKER_COMMAND:-""} - privileged: true - cgroupns_mode: host - pre_build_image: true - environment: - container: docker - security_opts: - - apparmor=unconfined - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:rw - - /lib/modules:/lib/modules:ro provisioner: name: ansible config_options: connection: pipelining: true + defaults: + callbacks_enabled: ansible.posix.profile_tasks verifier: name: ansible diff --git a/molecule/forget-package/prepare.yml b/molecule/forget-package/prepare.yml index 2023adb..05ca656 100644 --- a/molecule/forget-package/prepare.yml +++ b/molecule/forget-package/prepare.yml @@ -15,23 +15,7 @@ - name: Prepare hosts: all become: true - pre_tasks: - - name: Wait for systemd to complete initialization - 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 - changed_when: false - failed_when: systemctl_status.rc > 1 tasks: - - name: Run APT update - ansible.builtin.apt: - update_cache: yes - when: ansible_facts['pkg_mgr'] == "apt" - - name: Install NGINX ansible.builtin.package: name: nginx diff --git a/molecule/nerdctl/create.yml b/molecule/nerdctl/create.yml new file mode 100644 index 0000000..267c81d --- /dev/null +++ b/molecule/nerdctl/create.yml @@ -0,0 +1,19 @@ +# Copyright (c) 2024 VEXXHOST, Inc. +# SPDX-License-Identifier: Apache-2.0 + +- name: Wait for user to read warning + hosts: localhost + tasks: + - name: Wait for user to read warning + ignore_errors: true # noqa: ignore-errors + ansible.builtin.fail: + msg: >- + ⚠️ + This code will make substantial changes to your machine, it is strongly + recommended that you run this on a server or virtual machine that you + dedicate to this purpose. + ⚠️ + + - name: Wait for user to read warning + ansible.builtin.wait_for: + timeout: 15 diff --git a/molecule/nerdctl/molecule.yml b/molecule/nerdctl/molecule.yml index 975d730..1383dbd 100644 --- a/molecule/nerdctl/molecule.yml +++ b/molecule/nerdctl/molecule.yml @@ -1,39 +1,23 @@ # Copyright (c) 2024 VEXXHOST, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. +# SPDX-License-Identifier: Apache-2.0 dependency: name: galaxy driver: - name: docker + name: default + options: + managed: False + ansible_connection_options: + ansible_become: "true" + ansible_connection: local platforms: - name: instance - image: geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest - command: ${MOLECULE_DOCKER_COMMAND:-""} - privileged: true - cgroupns_mode: host - pre_build_image: true - environment: - container: docker - security_opts: - - apparmor=unconfined - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:rw - - /lib/modules:/lib/modules:ro provisioner: name: ansible config_options: connection: pipelining: true + defaults: + callbacks_enabled: ansible.posix.profile_tasks verifier: name: ansible diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..7580c0f --- /dev/null +++ b/tox.ini @@ -0,0 +1,33 @@ +[tox] +minversion = 4 +skipsdist = True + +[testenv:molecule-venv] +deps = + molecule +commands = + molecule {posargs} + +[testenv:molecule-containerd] +deps = + {[testenv:molecule-venv]deps} +commands = + molecule test -s containerd + +[testenv:molecule-docker] +deps = + {[testenv:molecule-venv]deps} +commands = + molecule test -s docker + +[testenv:molecule-forget-package] +deps = + {[testenv:molecule-venv]deps} +commands = + molecule test -s forget-package + +[testenv:molecule-nerdctl] +deps = + {[testenv:molecule-venv]deps} +commands = + molecule test -s nerdctl diff --git a/molecule/nerdctl/prepare.yml b/zuul.d/playbooks/molecule/pre.yml similarity index 53% rename from molecule/nerdctl/prepare.yml rename to zuul.d/playbooks/molecule/pre.yml index cd5e7e6..b401bb5 100644 --- a/molecule/nerdctl/prepare.yml +++ b/zuul.d/playbooks/molecule/pre.yml @@ -12,22 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. -- name: Prepare +- name: Prepare host for Molecule tests hosts: all - become: true - pre_tasks: - - name: Wait for systemd to complete initialization - 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 - changed_when: false - failed_when: systemctl_status.rc > 1 tasks: - - name: Run APT update - ansible.builtin.apt: - update_cache: yes - when: ansible_facts['pkg_mgr'] == "apt" + - name: Disable swap + become: true + ansible.builtin.command: swapoff -a + ignore_errors: yes diff --git a/zuul.d/playbooks/molecule/run.yml b/zuul.d/playbooks/molecule/run.yml new file mode 100644 index 0000000..dc852f7 --- /dev/null +++ b/zuul.d/playbooks/molecule/run.yml @@ -0,0 +1,18 @@ +# Copyright (c) 2024 VEXXHOST, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +- hosts: all + become: true + roles: + - tox diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 5e57a38..1c584c9 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -12,13 +12,84 @@ # License for the specific language governing permissions and limitations # under the License. +- job: + name: ansible-collection-kubernetes-molecule + parent: tox + abstract: true + pre-run: zuul.d/playbooks/molecule/pre.yml + run: zuul.d/playbooks/molecule/run.yml + +- job: + name: ansible-collection-kubernetes-molecule-focal + parent: ansible-collection-kubernetes-molecule + +- job: + name: ansible-collection-kubernetes-molecule-focal-containerd + parent: ansible-collection-kubernetes-molecule-focal + vars: + tox_envlist: molecule-containerd + +- job: + name: ansible-collection-kubernetes-molecule-focal-docker + parent: ansible-collection-kubernetes-molecule-focal + vars: + tox_envlist: molecule-docker + +- job: + name: ansible-collection-kubernetes-molecule-focal-forget-package + parent: ansible-collection-kubernetes-molecule-focal + vars: + tox_envlist: molecule-forget-package + +- job: + name: ansible-collection-kubernetes-molecule-focal-nerdctl + parent: ansible-collection-kubernetes-molecule-focal + vars: + tox_envlist: molecule-nerdctl + +- job: + name: ansible-collection-kubernetes-molecule-jammy + parent: ansible-collection-kubernetes-molecule + +- job: + name: ansible-collection-kubernetes-molecule-jammy-containerd + parent: ansible-collection-kubernetes-molecule-jammy + vars: + tox_envlist: molecule-containerd + +- job: + name: ansible-collection-kubernetes-molecule-jammy-docker + parent: ansible-collection-kubernetes-molecule-jammy + vars: + tox_envlist: molecule-docker + +- job: + name: ansible-collection-kubernetes-molecule-jammy-nerdctl + parent: ansible-collection-kubernetes-molecule-jammy + vars: + tox_envlist: molecule-nerdctl + - project: merge-mode: squash-merge check: jobs: + - ansible-collection-kubernetes-molecule-focal-containerd + - ansible-collection-kubernetes-molecule-focal-docker + - ansible-collection-kubernetes-molecule-focal-forget-package + - ansible-collection-kubernetes-molecule-focal-nerdctl + - ansible-collection-kubernetes-molecule-jammy-containerd + - ansible-collection-kubernetes-molecule-jammy-docker + - ansible-collection-kubernetes-molecule-jammy-nerdctl - build-ansible-collection gate: jobs: + - ansible-collection-kubernetes-molecule-focal-containerd + - ansible-collection-kubernetes-molecule-focal-docker + - ansible-collection-kubernetes-molecule-focal-forget-package + - ansible-collection-kubernetes-molecule-focal-nerdctl + - ansible-collection-kubernetes-molecule-jammy-containerd + - ansible-collection-kubernetes-molecule-jammy-docker + - ansible-collection-kubernetes-molecule-jammy-nerdctl - build-ansible-collection release: jobs: From 9b2a80c283efbcb9908f6db1830540795bcca180 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Mon, 5 Aug 2024 10:24:44 -0700 Subject: [PATCH 02/12] Add nodeset --- zuul.d/project.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 1c584c9..a6fde7c 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -22,6 +22,10 @@ - job: name: ansible-collection-kubernetes-molecule-focal parent: ansible-collection-kubernetes-molecule + nodeset: + nodes: + - name: ubuntu-focal + label: focal-2c-8g - job: name: ansible-collection-kubernetes-molecule-focal-containerd @@ -50,6 +54,10 @@ - job: name: ansible-collection-kubernetes-molecule-jammy parent: ansible-collection-kubernetes-molecule + nodeset: + nodes: + - name: ubuntu-jammy + label: jammy-2c-8g - job: name: ansible-collection-kubernetes-molecule-jammy-containerd From 0f17bd806ca8bcddac63d86c6f5c5aeaf774c558 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Mon, 5 Aug 2024 10:28:40 -0700 Subject: [PATCH 03/12] Add "docker-image-py" dependency --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 7580c0f..25e38fd 100644 --- a/tox.ini +++ b/tox.ini @@ -5,6 +5,7 @@ skipsdist = True [testenv:molecule-venv] deps = molecule + docker-image-py commands = molecule {posargs} From 501d2fa3eb24e52b4aaa7818b2b92a6b382639a2 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Mon, 5 Aug 2024 10:28:50 -0700 Subject: [PATCH 04/12] Remove from GHA --- .github/workflows/molecule.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml index 0cf6b19..f03996b 100644 --- a/.github/workflows/molecule.yml +++ b/.github/workflows/molecule.yml @@ -33,11 +33,6 @@ jobs: distro: - rockylinux8 - rockylinux9 - - ubuntu2004 - - ubuntu2204 - include: - - scenario: forget-package - distro: ubuntu2004 steps: - name: Checkout project uses: actions/checkout@v3 From a58531be99cc6945b833f429711d5df82dc89e0f Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Mon, 5 Aug 2024 10:50:47 -0700 Subject: [PATCH 05/12] Add RockyLinux jobs --- .github/workflows/molecule.yml | 55 ----------------------------- zuul.d/project.yaml | 64 ++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 55 deletions(-) delete mode 100644 .github/workflows/molecule.yml diff --git a/.github/workflows/molecule.yml b/.github/workflows/molecule.yml deleted file mode 100644 index f03996b..0000000 --- a/.github/workflows/molecule.yml +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (c) 2023 VEXXHOST, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -name: molecule - -on: - pull_request: - push: - branches: - - main - -jobs: - test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - scenario: - - containerd - - docker - - nerdctl - distro: - - rockylinux8 - - rockylinux9 - steps: - - name: Checkout project - uses: actions/checkout@v3 - - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: "3.10" - cache: pip - - - name: Install Molecule - run: pip install -r requirements.txt - - - name: Turn off swap - run: sudo swapoff -a - - - name: Run Molecule - run: molecule test -s ${{ matrix.scenario }} - env: - MOLECULE_DISTRO: ${{ matrix.distro }} diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index a6fde7c..199d5b9 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -77,6 +77,58 @@ vars: tox_envlist: molecule-nerdctl +- job: + name: ansible-collection-kubernetes-molecule-rockylinux8 + parent: ansible-collection-kubernetes-molecule + nodeset: + nodes: + - name: rockylinux8 + label: rockylinux8-2c-8g + +- job: + name: ansible-collection-kubernetes-molecule-rockylinux8-containerd + parent: ansible-collection-kubernetes-molecule-rockylinux8 + vars: + tox_envlist: molecule-containerd + +- job: + name: ansible-collection-kubernetes-molecule-rockylinux8-docker + parent: ansible-collection-kubernetes-molecule-rockylinux8 + vars: + tox_envlist: molecule-docker + +- job: + name: ansible-collection-kubernetes-molecule-rockylinux8-nerdctl + parent: ansible-collection-kubernetes-molecule-rockylinux8 + vars: + tox_envlist: molecule-nerdctl + +- job: + name: ansible-collection-kubernetes-molecule-rockylinux9 + parent: ansible-collection-kubernetes-molecule + nodeset: + nodes: + - name: rockylinux9 + label: rockylinux9-2c-8g + +- job: + name: ansible-collection-kubernetes-molecule-rockylinux9-containerd + parent: ansible-collection-kubernetes-molecule-rockylinux9 + vars: + tox_envlist: molecule-containerd + +- job: + name: ansible-collection-kubernetes-molecule-rockylinux9-docker + parent: ansible-collection-kubernetes-molecule-rockylinux9 + vars: + tox_envlist: molecule-docker + +- job: + name: ansible-collection-kubernetes-molecule-rockylinux9-nerdctl + parent: ansible-collection-kubernetes-molecule-rockylinux9 + vars: + tox_envlist: molecule-nerdctl + - project: merge-mode: squash-merge check: @@ -88,6 +140,12 @@ - ansible-collection-kubernetes-molecule-jammy-containerd - ansible-collection-kubernetes-molecule-jammy-docker - ansible-collection-kubernetes-molecule-jammy-nerdctl + - ansible-collection-kubernetes-molecule-rockylinux8-containerd + - ansible-collection-kubernetes-molecule-rockylinux8-docker + - ansible-collection-kubernetes-molecule-rockylinux8-nerdctl + - ansible-collection-kubernetes-molecule-rockylinux9-containerd + - ansible-collection-kubernetes-molecule-rockylinux9-docker + - ansible-collection-kubernetes-molecule-rockylinux9-nerdctl - build-ansible-collection gate: jobs: @@ -98,6 +156,12 @@ - ansible-collection-kubernetes-molecule-jammy-containerd - ansible-collection-kubernetes-molecule-jammy-docker - ansible-collection-kubernetes-molecule-jammy-nerdctl + - ansible-collection-kubernetes-molecule-rockylinux8-containerd + - ansible-collection-kubernetes-molecule-rockylinux8-docker + - ansible-collection-kubernetes-molecule-rockylinux8-nerdctl + - ansible-collection-kubernetes-molecule-rockylinux9-containerd + - ansible-collection-kubernetes-molecule-rockylinux9-docker + - ansible-collection-kubernetes-molecule-rockylinux9-nerdctl - build-ansible-collection release: jobs: From f04a37b1656ac36a88dab686c49b23897c3d68fe Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Mon, 5 Aug 2024 11:16:25 -0700 Subject: [PATCH 06/12] Drop minversion for tox --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index 25e38fd..30d8cb8 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,4 @@ [tox] -minversion = 4 skipsdist = True [testenv:molecule-venv] From 251b7c23ed84fe4ba7a0443c7aa404c4d3d52598 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Mon, 5 Aug 2024 11:25:06 -0700 Subject: [PATCH 07/12] Install PIP from upstream --- zuul.d/project.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 199d5b9..9a34c09 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -106,6 +106,9 @@ - job: name: ansible-collection-kubernetes-molecule-rockylinux9 parent: ansible-collection-kubernetes-molecule + vars: + # NOTE(mnaser): `python3-wheel` is not available on Rocky 9. + ensure_pip_from_upstream: true nodeset: nodes: - name: rockylinux9 From 48454a1d90494c09900316ecde99e8f547c45cd0 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Mon, 5 Aug 2024 11:33:35 -0700 Subject: [PATCH 08/12] Update Python version --- .python-version | 1 + zuul.d/project.yaml | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 .python-version diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..c8cfe39 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.10 diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 9a34c09..2b74752 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -22,6 +22,9 @@ - job: name: ansible-collection-kubernetes-molecule-focal parent: ansible-collection-kubernetes-molecule + vars: + # NOTE(mnaser): Ubuntu Focal ships with an old Python + python_use_pyenv: true nodeset: nodes: - name: ubuntu-focal @@ -80,6 +83,9 @@ - job: name: ansible-collection-kubernetes-molecule-rockylinux8 parent: ansible-collection-kubernetes-molecule + vars: + # NOTE(mnaser): Rocky 8 ships with an old Python + python_use_pyenv: true nodeset: nodes: - name: rockylinux8 @@ -108,6 +114,7 @@ parent: ansible-collection-kubernetes-molecule vars: # NOTE(mnaser): `python3-wheel` is not available on Rocky 9. + ensure_pip_from_packages: false ensure_pip_from_upstream: true nodeset: nodes: From 33562cf645a21bcf3a9746aef2a26037f5edb1e3 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Mon, 5 Aug 2024 11:45:44 -0700 Subject: [PATCH 09/12] Moved linters --- .flake8 | 2 ++ .github/workflows/linters.yml | 33 ----------------- .pre-commit-config.yaml | 26 +++++++++----- README.md | 2 +- meta/runtime.yml | 2 +- plugins/filter/docker_image.py | 66 +++++++++++++++++----------------- tox.ini | 6 ++++ zuul.d/project.yaml | 4 +++ 8 files changed, 64 insertions(+), 77 deletions(-) create mode 100644 .flake8 delete mode 100644 .github/workflows/linters.yml diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..6deafc2 --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +max-line-length = 120 diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml deleted file mode 100644 index 56df98a..0000000 --- a/.github/workflows/linters.yml +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (c) 2023 VEXXHOST, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -name: linters - -on: - pull_request: - push: - branches: - - main - -jobs: - ansible-lint: - runs-on: ubuntu-latest - steps: - - name: Checkout project - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Run "ansible-lint" - uses: ansible/ansible-lint-action@main diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a21c91e..967bf2f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,4 @@ -exclude: '^(charts)' +exclude: '^(roles/kube_prometheus_stack/files/jsonnet|charts)' repos: - repo: https://github.com/pre-commit/pre-commit-hooks @@ -7,15 +7,23 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/compilerla/conventional-pre-commit - rev: v2.0.0 + - repo: https://github.com/psf/black + rev: 24.4.0 hooks: - - id: conventional-pre-commit - stages: - - commit-msg + - id: black - - repo: https://github.com/ansible/ansible-lint - rev: v6.13.1 + - repo: https://github.com/pycqa/flake8 + rev: 7.0.0 + hooks: + - id: flake8 + + - repo: https://github.com/pycqa/isort + rev: 5.13.2 + hooks: + - id: isort + args: ["--profile", "black", "--filter-files"] + + - repo: https://github.com/ansible/ansible-lint.git + rev: v24.7.0 hooks: - id: ansible-lint - files: \.(yaml|yml)$ diff --git a/README.md b/README.md index f6145a4..a3e7e45 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Ansible collection for containers This is a collection which contains playbooks and roles which allow you to -deploy container runtimes using Ansible. This collection is used by the +deploy container runtimes using Ansible. This collection is used by the [Atmosphere](https://github.com/vexxhost/atmosphere) project. ## Contributing diff --git a/meta/runtime.yml b/meta/runtime.yml index 33f1892..1e85b01 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -1,2 +1,2 @@ --- -requires_ansible: ">=2.13.4" +requires_ansible: ">=2.15.0" diff --git a/plugins/filter/docker_image.py b/plugins/filter/docker_image.py index ba93065..778d2c3 100644 --- a/plugins/filter/docker_image.py +++ b/plugins/filter/docker_image.py @@ -27,45 +27,45 @@ HAS_DOCKER_IMAGE = False DOCUMENTATION = """ - name: docker_image - short_description: Parse a Docker image reference - version_added: 0.13.0 - description: - - Parse a Docker image and return different parts of the reference - - This lookup module requires "docker-image-py" to be installed on the - Ansible controller. - options: - _input: - type: string - required: true - description: - - Docker image reference to parse - part: - type: string - default: 'ref' - options: [name, ref, tag, domain, path] - required: true - description: - - Part of the Docker image reference to return - registry: - type: string - required: false - description: - - Override the registry in the Docker image reference - author: - - Mohammed Naser +name: docker_image +short_description: Parse a Docker image reference +version_added: 0.13.0 +description: + - Parse a Docker image and return different parts of the reference + - This lookup module requires "docker-image-py" to be installed on the + Ansible controller. +options: + _input: + type: string + required: true + description: + - Docker image reference to parse + part: + type: string + default: 'ref' + options: [name, ref, tag, domain, path] + required: true + description: + - Part of the Docker image reference to return + registry: + type: string + required: false + description: + - Override the registry in the Docker image reference +author: + - Mohammed Naser """ EXAMPLES = """ - - name: Generate a Docker image reference - ansible.builtin.debug: - msg: "{{ 'docker.io/library/memcached:1.6.22' | vexxhost.kubernetes.docker_image('name') }}" +- name: Generate a Docker image reference + ansible.builtin.debug: + msg: "{{ 'docker.io/library/memcached:1.6.22' | vexxhost.kubernetes.docker_image('name') }}" """ RETURN = """ - _value: - description: The part of the Docker image reference - type: string +_value: + description: The part of the Docker image reference + type: string """ diff --git a/tox.ini b/tox.ini index 30d8cb8..3c182b6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,12 @@ [tox] skipsdist = True +[testenv:linters] +deps = + pre-commit +commands = + pre-commit run --all-files --show-diff-on-failure + [testenv:molecule-venv] deps = molecule diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 2b74752..57d2a99 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -12,6 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. +- job: + name: ansible-collection-kubernetes-linters + parent: tox-linters + - job: name: ansible-collection-kubernetes-molecule parent: tox From 5ef8212fe0acb2147d325ea35c103bd57d6eb2b0 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Mon, 5 Aug 2024 11:46:19 -0700 Subject: [PATCH 10/12] Run the linters job --- zuul.d/project.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 57d2a99..9bffeaf 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -147,6 +147,7 @@ merge-mode: squash-merge check: jobs: + - ansible-collection-kubernetes-linters - ansible-collection-kubernetes-molecule-focal-containerd - ansible-collection-kubernetes-molecule-focal-docker - ansible-collection-kubernetes-molecule-focal-forget-package @@ -163,6 +164,7 @@ - build-ansible-collection gate: jobs: + - ansible-collection-kubernetes-linters - ansible-collection-kubernetes-molecule-focal-containerd - ansible-collection-kubernetes-molecule-focal-docker - ansible-collection-kubernetes-molecule-focal-forget-package From e2d42f18177e0207c8700a28a42e6fdd0e14c2e8 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Mon, 5 Aug 2024 12:00:22 -0700 Subject: [PATCH 11/12] Move some jobs to non voting --- zuul.d/project.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 9bffeaf..54192e6 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -87,6 +87,8 @@ - job: name: ansible-collection-kubernetes-molecule-rockylinux8 parent: ansible-collection-kubernetes-molecule + # https://github.com/vexxhost/ansible-collection-containers/issues/28 + voting: false vars: # NOTE(mnaser): Rocky 8 ships with an old Python python_use_pyenv: true @@ -128,6 +130,8 @@ - job: name: ansible-collection-kubernetes-molecule-rockylinux9-containerd parent: ansible-collection-kubernetes-molecule-rockylinux9 + # https://github.com/vexxhost/ansible-collection-containers/issues/27 + voting: false vars: tox_envlist: molecule-containerd From e6cb4288bea8d8935222eb5289cadd2803aca6c2 Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Mon, 5 Aug 2024 12:01:22 -0700 Subject: [PATCH 12/12] Added noble jobs --- zuul.d/project.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 54192e6..42c0c26 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -84,6 +84,32 @@ vars: tox_envlist: molecule-nerdctl +- job: + name: ansible-collection-kubernetes-molecule-noble + parent: ansible-collection-kubernetes-molecule + nodeset: + nodes: + - name: ubuntu-noble + label: noble-2c-8g + +- job: + name: ansible-collection-kubernetes-molecule-noble-containerd + parent: ansible-collection-kubernetes-molecule-noble + vars: + tox_envlist: molecule-containerd + +- job: + name: ansible-collection-kubernetes-molecule-noble-docker + parent: ansible-collection-kubernetes-molecule-noble + vars: + tox_envlist: molecule-docker + +- job: + name: ansible-collection-kubernetes-molecule-noble-nerdctl + parent: ansible-collection-kubernetes-molecule-noble + vars: + tox_envlist: molecule-nerdctl + - job: name: ansible-collection-kubernetes-molecule-rockylinux8 parent: ansible-collection-kubernetes-molecule @@ -159,6 +185,9 @@ - ansible-collection-kubernetes-molecule-jammy-containerd - ansible-collection-kubernetes-molecule-jammy-docker - ansible-collection-kubernetes-molecule-jammy-nerdctl + - ansible-collection-kubernetes-molecule-noble-containerd + - ansible-collection-kubernetes-molecule-noble-docker + - ansible-collection-kubernetes-molecule-noble-nerdctl - ansible-collection-kubernetes-molecule-rockylinux8-containerd - ansible-collection-kubernetes-molecule-rockylinux8-docker - ansible-collection-kubernetes-molecule-rockylinux8-nerdctl