From 0fcb9da9c029ec013d0218d8152cbd0503f973d6 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 16 Jun 2021 14:19:04 +0100 Subject: [PATCH] Ensure that containers.podman collection is present (#40) Adds check for presence of containers.podman collection and requires the latest known version to present. This means that this driver will no longer work with podman modules shipped with Ansible 2.9. Still, installing the collection on 2.9 will make it work but that must be run by the user. --- .pre-commit-config.yaml | 4 +++- README.rst | 6 +++++- lib/molecule_podman/driver.py | 2 ++ setup.cfg | 2 ++ tox.ini | 4 +++- 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e4db00e..710e226 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,6 +50,7 @@ repos: entry: mypy lib/ pass_filenames: false additional_dependencies: + - ansible-lint>=5.1.0a0 - molecule - packaging - repo: https://github.com/pre-commit/mirrors-pylint @@ -57,5 +58,6 @@ repos: hooks: - id: pylint additional_dependencies: - - ansible-base + - ansible-core>=2.11.1 + - ansible-lint>=5.1.0a0 - molecule diff --git a/README.rst b/README.rst index 88b411f..153bf39 100644 --- a/README.rst +++ b/README.rst @@ -17,9 +17,13 @@ Molecule Podman Plugin :target: LICENSE :alt: Repository License -Molecule podman Plugin is designed to allow use Podman containers for +Molecule Podman Plugin is designed to allow use Podman containers for provisioning test resources. +This plugin requires `containers.podman` collection to be present: + + ansible-galaxy collection install containers.podman + Please note that this driver is currently in its early stage of development. .. _get-involved: diff --git a/lib/molecule_podman/driver.py b/lib/molecule_podman/driver.py index bbc9f09..4be51d5 100644 --- a/lib/molecule_podman/driver.py +++ b/lib/molecule_podman/driver.py @@ -23,6 +23,7 @@ import os +from ansiblelint.prerun import require_collection from molecule import logger from molecule.api import Driver from molecule.util import lru_cache @@ -189,3 +190,4 @@ def ansible_connection_options(self, instance_name): def sanity_checks(self): """Implement Podman driver sanity checks.""" log.info("Sanity checks: '{}'".format(self._name)) + require_collection("containers.podman", "1.6.1") diff --git a/setup.cfg b/setup.cfg index 6e2b3c2..2c12443 100644 --- a/setup.cfg +++ b/setup.cfg @@ -66,6 +66,8 @@ setup_requires = # These are required in actual runtime: install_requires = + # we need require_collection from ansiblelint.prerun + ansible-lint >= 5.1.0a0 molecule >= 3.2.0 # selinux python module is needed as least by ansible-podman modules # and allows us of isolated (default) virtualenvs. It does not avoid need diff --git a/tox.ini b/tox.ini index 7fa872f..4711701 100644 --- a/tox.ini +++ b/tox.ini @@ -43,7 +43,9 @@ deps = dockerfile: ansible>=2.9.12 selinux commands = - ansibledevel: ansible-galaxy install git+https://github.com/ansible-collections/community.general.git + ansibledevel: ansible-galaxy collection install git+https://github.com/containers/ansible-podman-collections + # this should mention oldest version we find acceptable for runtime + ansible-galaxy collection install 'containers.podman:==1.6.1' # failsafe as pip may install incompatible dependencies pip check # failsafe for preventing changes that may break pytest collection