From 51d24d59ed8e60009c68c40efc1859f8e3b1010b Mon Sep 17 00:00:00 2001 From: Richard Megginson Date: Wed, 13 Dec 2023 12:38:35 -0700 Subject: [PATCH] Use ansible-lint from pip - the container is deprecated (#151) The ansible-lint container is deprecated, so use ansible-lint from pypi instead. --- README.md | 7 ++++++- src/tox_lsr/config_files/tox-default.ini | 20 ++++++------------ tests/fixtures/test_tox_merge_ini/result.ini | 22 ++++++-------------- 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 41c84e1..5c54000 100644 --- a/README.md +++ b/README.md @@ -292,7 +292,7 @@ environment variables: * `RUN_YAMLLINT_EXTRA_ARGS` - extra command line arguments to provide to yamllint * `RUN_ANSIBLE_LINT_EXTRA_ARGS` - extra command line arguments to provide to - ansible-lint + ansible-lint and ansible-lint-collection * `LSR_ROLE2COLL_VERSION` - a tag/commit of the lsr_role2collection script to use for the collection tox test. The default is the latest stable version. * `LSR_ROLE2COLL_NAMESPACE` - namespace to use for the lsr_role2collection @@ -383,6 +383,11 @@ This will convert your role to a collection, run `ansible-test` with only the `ansible-doc` test, and dump what the converted doc looks like, or dump errors if your doc could not be rendered correctly. +To run `ansible-lint-collection` you must first convert to collection. +``` +> tox -e collection,ansible-lint-collection +``` + ### QEMU testing Integration tests are run using qemu/kvm using the test playbooks in the diff --git a/src/tox_lsr/config_files/tox-default.ini b/src/tox_lsr/config_files/tox-default.ini index 3217b45..bd49830 100644 --- a/src/tox_lsr/config_files/tox-default.ini +++ b/src/tox_lsr/config_files/tox-default.ini @@ -30,7 +30,6 @@ setenv = LSR_ROLE2COLL_NAMESPACE = fedora LSR_ROLE2COLL_NAME = linux_system_roles LSR_TOX_ENV_TMP_DIR = {envtmpdir} - LSR_ANSIBLE_LINT_CONTAINER = {env:LSR_ANSIBLE_LINT_CONTAINER:quay.io/ansible/creator-ee:v0.19.0} deps = py{26,27,36,37,38,39,310,311}: pytest-cov py{27,36,37,38,39,310,311}: pytest>=3.5.1 @@ -236,18 +235,15 @@ commands = [testenv:ansible-lint] changedir = {toxinidir} allowlist_externals = - podman bash +deps = + ansible-lint commands_pre = bash {lsr_scriptdir}/ansible-lint-helper.sh pre commands = bash {lsr_scriptdir}/setup_module_utils.sh {[lsr_config]commands_pre} - {env:LSR_CONTAINER_RUNTIME:podman} run --rm --privileged \ - -v {toxinidir}:/workdir --workdir /workdir \ - --entrypoint /usr/local/bin/ansible-lint \ - {env:LSR_ANSIBLE_LINT_CONTAINER} \ - {env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs} + ansible-lint {env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs} {[lsr_config]commands_post} commands_post = bash {lsr_scriptdir}/ansible-lint-helper.sh post @@ -255,19 +251,15 @@ commands_post = [testenv:ansible-lint-collection] changedir = {toxworkdir}/ansible_collections/{env:LSR_ROLE2COLL_NAMESPACE}/{env:LSR_ROLE2COLL_NAME} allowlist_externals = - podman bash cp +deps = + ansible-lint commands = bash {lsr_scriptdir}/setup_module_utils.sh {[lsr_config]commands_pre} cp {toxinidir}/.ansible-lint {toxworkdir}/ansible_collections/{env:LSR_ROLE2COLL_NAMESPACE}/{env:LSR_ROLE2COLL_NAME} - {env:LSR_CONTAINER_RUNTIME:podman} run --rm --privileged \ - -v {toxworkdir}/ansible_collections/{env:LSR_ROLE2COLL_NAMESPACE}/{env:LSR_ROLE2COLL_NAME}:/workdir \ - --workdir /workdir \ - --entrypoint /usr/local/bin/ansible-lint \ - {env:LSR_ANSIBLE_LINT_CONTAINER} \ - {env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs} + ansible-lint {env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs} {[lsr_config]commands_post} [testenv:ansible-test] diff --git a/tests/fixtures/test_tox_merge_ini/result.ini b/tests/fixtures/test_tox_merge_ini/result.ini index 68604e9..ef52a0f 100644 --- a/tests/fixtures/test_tox_merge_ini/result.ini +++ b/tests/fixtures/test_tox_merge_ini/result.ini @@ -26,7 +26,6 @@ setenv = PYTHONPATH = {env:LSR_PYTHONPATH:}{toxinidir}/library:{toxinidir}/modul LSR_ROLE2COLL_NAMESPACE = fedora LSR_ROLE2COLL_NAME = linux_system_roles LSR_TOX_ENV_TMP_DIR = {envtmpdir} - LSR_ANSIBLE_LINT_CONTAINER = {env:LSR_ANSIBLE_LINT_CONTAINER:quay.io/ansible/creator-ee:v0.19.0} LOCAL1 = local1 LOCAL2 = local2 deps = py{26,27,36,37,38,39,310,311}: pytest-cov @@ -197,33 +196,24 @@ commands = bash {lsr_scriptdir}/setup_module_utils.sh [testenv:ansible-lint] changedir = {toxinidir} -allowlist_externals = podman - bash +allowlist_externals = bash +deps = ansible-lint commands_pre = bash {lsr_scriptdir}/ansible-lint-helper.sh pre commands = bash {lsr_scriptdir}/setup_module_utils.sh {[lsr_config]commands_pre} - {env:LSR_CONTAINER_RUNTIME:podman} run --rm --privileged \ - -v {toxinidir}:/workdir --workdir /workdir \ - --entrypoint /usr/local/bin/ansible-lint \ - {env:LSR_ANSIBLE_LINT_CONTAINER} \ - {env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs} + ansible-lint {env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs} {[lsr_config]commands_post} commands_post = bash {lsr_scriptdir}/ansible-lint-helper.sh post [testenv:ansible-lint-collection] changedir = {toxworkdir}/ansible_collections/{env:LSR_ROLE2COLL_NAMESPACE}/{env:LSR_ROLE2COLL_NAME} -allowlist_externals = podman - bash +allowlist_externals = bash cp +deps = ansible-lint commands = bash {lsr_scriptdir}/setup_module_utils.sh {[lsr_config]commands_pre} cp {toxinidir}/.ansible-lint {toxworkdir}/ansible_collections/{env:LSR_ROLE2COLL_NAMESPACE}/{env:LSR_ROLE2COLL_NAME} - {env:LSR_CONTAINER_RUNTIME:podman} run --rm --privileged \ - -v {toxworkdir}/ansible_collections/{env:LSR_ROLE2COLL_NAMESPACE}/{env:LSR_ROLE2COLL_NAME}:/workdir \ - --workdir /workdir \ - --entrypoint /usr/local/bin/ansible-lint \ - {env:LSR_ANSIBLE_LINT_CONTAINER} \ - {env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs} + ansible-lint {env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs} {[lsr_config]commands_post} [testenv:ansible-test]