Skip to content

Commit

Permalink
Use ansible-lint from pip - the container is deprecated (#151)
Browse files Browse the repository at this point in the history
The ansible-lint container is deprecated, so use ansible-lint from
pypi instead.
  • Loading branch information
richm authored Dec 13, 2023
1 parent 9e30554 commit 51d24d5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 31 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
20 changes: 6 additions & 14 deletions src/tox_lsr/config_files/tox-default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -236,38 +235,31 @@ 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

[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]
Expand Down
22 changes: 6 additions & 16 deletions tests/fixtures/test_tox_merge_ini/result.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 51d24d5

Please sign in to comment.