From 78f0441607c39986d7307f08c8a122e541c5b14c Mon Sep 17 00:00:00 2001 From: Nick Yang Date: Tue, 1 Oct 2024 07:59:12 -0500 Subject: [PATCH 1/2] implement reset for podman driver (#269) * implement reset for podman driver * when the podman driver runs the `create` playbook, we'll add a `owner=molecule` label to the containers we create * in `reset`, we'll delete containers (eventually everything?) that has the label `owner=molecule` * address PR feedback * hotfix filter/labels typo * use `label` instead of alias `labels` --- src/molecule_plugins/podman/driver.py | 6 +++++- src/molecule_plugins/podman/playbooks/create.yml | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/molecule_plugins/podman/driver.py b/src/molecule_plugins/podman/driver.py index 99c39090..5f7621c6 100644 --- a/src/molecule_plugins/podman/driver.py +++ b/src/molecule_plugins/podman/driver.py @@ -30,7 +30,7 @@ from molecule import logger, util from molecule.api import Driver, MoleculeRuntimeWarning from molecule.constants import RC_SETUP_ERROR -from molecule.util import sysexit_with_message +from molecule.util import run_command, sysexit_with_message log = logger.get_logger(__name__) @@ -243,3 +243,7 @@ def sanity_checks(self): def required_collections(self) -> dict[str, str]: """Return collections dict containing names and versions required.""" return {"containers.podman": "1.7.0", "ansible.posix": "1.3.0"} + + def reset(self): + # keep `--filter` in sync with playbooks/create.yml + run_command(["podman", "rm", "--force", "--filter=label=owner=molecule"]) diff --git a/src/molecule_plugins/podman/playbooks/create.yml b/src/molecule_plugins/podman/playbooks/create.yml index 5bc92cd9..57eab266 100644 --- a/src/molecule_plugins/podman/playbooks/create.yml +++ b/src/molecule_plugins/podman/playbooks/create.yml @@ -149,6 +149,8 @@ hostname: "{{ item.hostname | default(omit) }}" image: "{{ item.pre_build_image | default(false) | ternary('', 'molecule_local/') }}{{ item.image }}" ip: "{{ item.ip | default(omit) }}" + label: + owner: "molecule" # keep in sync with ../driver.py:Podman.reset() network: "{{ item.network | default(omit) }}" pid: "{{ item.pid_mode | default(omit) }}" privileged: "{{ item.privileged | default(omit) }}" From 36be097aaa4802ed4bcfdf0582554e657cba0d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sj=C3=B6gren?= Date: Wed, 2 Oct 2024 12:31:07 +0200 Subject: [PATCH 2/2] lint and update action paths (#258) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * lint and update action paths Signed-off-by: Thomas Sjögren * make it prettier Signed-off-by: Thomas Sjögren --------- Signed-off-by: Thomas Sjögren --- .github/workflows/ack.yml | 10 ++++++++-- .github/workflows/push.yml | 5 +++-- .github/workflows/release.yml | 1 + .github/workflows/tox.yml | 4 +++- README.md | 1 - test/gce/scenarios/linux/INSTALL.md | 8 ++++---- test/gce/scenarios/windows/INSTALL.md | 8 ++++---- 7 files changed, 23 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ack.yml b/.github/workflows/ack.yml index 5880addd..19944ed6 100644 --- a/.github/workflows/ack.yml +++ b/.github/workflows/ack.yml @@ -1,9 +1,15 @@ -# See https://github.com/ansible-community/devtools/blob/main/.github/workflows/ack.yml +--- +# See https://github.com/ansible/team-devtools/blob/main/.github/workflows/ack.yml name: ack + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + on: pull_request_target: types: [opened, labeled, unlabeled, synchronize] jobs: ack: - uses: ansible-community/devtools/.github/workflows/ack.yml@main + uses: ansible/team-devtools/.github/workflows/ack.yml@main diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ceef4e3c..029b3a8c 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,4 +1,5 @@ -# See https://github.com/ansible-community/devtools/blob/main/.github/workflows/push.yml +--- +# See https://github.com/ansible/team-devtools/blob/main/.github/workflows/push.yml name: push on: push: @@ -9,4 +10,4 @@ on: jobs: ack: - uses: ansible-community/devtools/.github/workflows/push.yml@main + uses: ansible/team-devtools/.github/workflows/push.yml@main diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ece598da..2fafccce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,3 +1,4 @@ +--- name: release on: diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 6a7e686e..0763b07b 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -1,3 +1,4 @@ +--- name: tox # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency @@ -40,7 +41,8 @@ jobs: matrix: ${{ fromJson(needs.pre.outputs.matrix) }} steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 with: fetch-depth: 0 # needed by setuptools-scm diff --git a/README.md b/README.md index 90ab2e3e..49ffb581 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ This repository contains the following molecule plugins: - podman - vagrant - Installing `molecule-plugins` does not install dependencies specific to each, plugin. To install these you need to install the extras for each plugin, like `pip3 install 'molecule-plugins[azure]'`. diff --git a/test/gce/scenarios/linux/INSTALL.md b/test/gce/scenarios/linux/INSTALL.md index 39c952e0..86c4ad56 100644 --- a/test/gce/scenarios/linux/INSTALL.md +++ b/test/gce/scenarios/linux/INSTALL.md @@ -2,7 +2,7 @@ ## Requirements -- A GCE credentials rc file +- A GCE credentials rc file ## Install @@ -11,9 +11,9 @@ installation best practices. If not using a virtual environment, please consider passing the widely recommended ['--user' flag][] when invoking `pip`. -``` bash +```bash $ pip install 'molecule_gce' ``` - [Virtual environment]: https://virtualenv.pypa.io/en/latest/ - ['--user' flag]: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site +[Virtual environment]: https://virtualenv.pypa.io/en/latest/ +['--user' flag]: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site diff --git a/test/gce/scenarios/windows/INSTALL.md b/test/gce/scenarios/windows/INSTALL.md index 39c952e0..86c4ad56 100644 --- a/test/gce/scenarios/windows/INSTALL.md +++ b/test/gce/scenarios/windows/INSTALL.md @@ -2,7 +2,7 @@ ## Requirements -- A GCE credentials rc file +- A GCE credentials rc file ## Install @@ -11,9 +11,9 @@ installation best practices. If not using a virtual environment, please consider passing the widely recommended ['--user' flag][] when invoking `pip`. -``` bash +```bash $ pip install 'molecule_gce' ``` - [Virtual environment]: https://virtualenv.pypa.io/en/latest/ - ['--user' flag]: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site +[Virtual environment]: https://virtualenv.pypa.io/en/latest/ +['--user' flag]: https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site