Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use official Ansible container for ansible-lint #100

Merged
merged 2 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ The following is an example of a `tox.ini` from the kernel_settings role:
lsr_enable = true
commands_pre = bash -c '{toxinidir}/tests/install_tuned_for_testing.sh || {toxinidir}/tests/kernel_settings/install_tuned_for_testing.sh'

[lsr_ansible-lint]
configfile = {toxinidir}/.ansible-lint

[lsr_yamllint]
configfile = {toxinidir}/.yamllint.yml
configbasename = .yamllint.yml
Expand Down Expand Up @@ -321,10 +318,6 @@ environment variables:
* `RUN_YAMLLINT_CONFIG_FILE` - path to config file to use instead of the default
* `LSR_ANSIBLE_TEST_DOCKER` - if set to `true`, `ansible-test` will be run with
`--docker`
* `LSR_ANSIBLE_LINT_DEP` - this is the dep to pass when doing the pip install of
ansible for ansible-lint. The default is `ansible-core==2.12.*`.
* `LSR_ANSIBLE_LINT_VER` - this is the version of ansible-lint to install for
the ansible-lint testenv. The default is `5.2.0`.
* `LSR_ANSIBLE_TEST_DEP` - this is the dep to pass when doing the pip install of
ansible for ansible-test. The default is `ansible-core==2.12.*`.
* `LSR_PYLINT_ANSIBLE_DEP` - this is the dep to pass when doing the pip install of
Expand Down
3 changes: 0 additions & 3 deletions src/tox_lsr/config_files/ansible-lint.yml

This file was deleted.

18 changes: 8 additions & 10 deletions src/tox_lsr/config_files/tox-default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -238,23 +238,21 @@ commands =
bash {lsr_scriptdir}/runshellcheck.sh
{[lsr_config]commands_post}

[lsr_ansible-lint]
configfile = {lsr_configdir}/ansible-lint.yml

[testenv:ansible-lint]
changedir = {toxinidir}
deps =
{env:LSR_ANSIBLE_LINT_DEP:ansible-core==2.14.*}
ansible-lint=={env:LSR_ANSIBLE_LINT_VER:5.*}
whitelist_externals =
podman
bash
commands_pre =
bash {lsr_scriptdir}/ansible-lint-helper.sh pre
commands =
bash {lsr_scriptdir}/setup_module_utils.sh
{[lsr_config]commands_pre}
ansible-lint -v --exclude=tests/roles --exclude=.github \
--exclude=.yamllint.yml \
-c {[lsr_ansible-lint]configfile} \
{env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs}
{env:LSR_CONTAINER_RUNTIME:podman} run --rm --privileged \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to add the description to README.md. But it's a very minor issue...

By default, it will use podman to run the container. You can set LSR_CONTAINER_RUNTIME to use a different runtime

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated
also deprecated several old env. vars.

-v {toxinidir}:/workdir --workdir /workdir \
--entrypoint /usr/local/bin/ansible-lint \
quay.io/ansible/creator-ee:v0.9.5 \
{env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs}
{[lsr_config]commands_post}
commands_post =
bash {lsr_scriptdir}/ansible-lint-helper.sh post
Expand Down
14 changes: 6 additions & 8 deletions tests/fixtures/test_tox_merge_ini/result.ini
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,17 @@ commands = bash {lsr_scriptdir}/setup_module_utils.sh
bash {lsr_scriptdir}/runshellcheck.sh
{[lsr_config]commands_post}

[lsr_ansible-lint]
configfile = {lsr_configdir}/ansible-lint.yml

[testenv:ansible-lint]
changedir = {toxinidir}
deps = {env:LSR_ANSIBLE_LINT_DEP:ansible-core==2.14.*}
ansible-lint=={env:LSR_ANSIBLE_LINT_VER:5.*}
whitelist_externals = podman
bash
commands_pre = bash {lsr_scriptdir}/ansible-lint-helper.sh pre
commands = bash {lsr_scriptdir}/setup_module_utils.sh
{[lsr_config]commands_pre}
ansible-lint -v --exclude=tests/roles --exclude=.github \
--exclude=.yamllint.yml \
-c {[lsr_ansible-lint]configfile} \
{env:LSR_CONTAINER_RUNTIME:podman} run --rm --privileged \
-v {toxinidir}:/workdir --workdir /workdir \
--entrypoint /usr/local/bin/ansible-lint \
quay.io/ansible/creator-ee:v0.9.5 \
{env:RUN_ANSIBLE_LINT_EXTRA_ARGS:} {posargs}
{[lsr_config]commands_post}
commands_post = bash {lsr_scriptdir}/ansible-lint-helper.sh post
Expand Down