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

Add support for acceptable command options #1457

Closed
wants to merge 16 commits into from
Closed

Add support for acceptable command options #1457

wants to merge 16 commits into from

Conversation

konstruktoid
Copy link
Contributor

@konstruktoid konstruktoid commented Mar 11, 2021

This PR is meant to reduce the number of false positives when command: is required due to missing module functionality.

E.g. command: systemctl set-default (#682) is acceptable since the Ansible systemd module don't have runlevel support.

Added 'git': 'branch', and 'systemctl': ['set-default', 'show-environment'] as initial examples.

Fixes: #682

Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
@aminvakil
Copy link
Contributor

I'm just asking this out of curiosity, what will happen when systemd module in ansible/ansible repo adds this feature?
That would be a thing I except from ansible-lint to fail when I'm using command instead of it.

Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
@konstruktoid
Copy link
Contributor Author

I'm just asking this out of curiosity, what will happen when systemd module in ansible/ansible repo adds this feature?
That would be a thing I except from ansible-lint to fail when I'm using command instead of it.

If the Ansible systemd modules adds set-default, then you would be using the systemd module and thus pass the command-instead-of-module rule anyway (since it only checks _commands = ['command', 'shell']).

Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
@konstruktoid
Copy link
Contributor Author

Label check fails, https://github.com/ansible-community/ansible-lint/pull/1457/checks?check_run_id=2087012753#step:4:13, but I don't seem to be able to add a label.

@ssbarnea ssbarnea self-requested a review March 11, 2021 15:28
.flake8 Outdated Show resolved Hide resolved
@ssbarnea
Copy link
Member

@konstruktoid Can you fix current issues, I want to merge this PR as I see beneficial. Removing few false-positives will make the rule more useful.

@konstruktoid
Copy link
Contributor Author

Will fix later today.

Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
…ISSUE682

* 'ISSUE682' of github.com:konstruktoid/ansible-lint:
  Avoid pre-run errors when role-name is disabled (#1459)
  Avoid exception when git is missing (#1456)
  Improve how we determine runtime verbosity
@ssbarnea
Copy link
Member

@konstruktoid I am closing this as not being updated but if you can find time to work on it, I will gladly reopen.

@ssbarnea ssbarnea closed this Mar 23, 2021
@konstruktoid
Copy link
Contributor Author

What do you mean not being updated @ssbarnea?

@ssbarnea
Copy link
Member

Last change was 11 days ago and it was reporting red on CI. I reopened it but it already missed being included in 5.0.5

@ssbarnea ssbarnea reopened this Mar 23, 2021
@konstruktoid
Copy link
Contributor Author

Yeah, I was waiting for #1457 (comment) and multiple tests fails on https://github.com/ansible-community/ansible-lint/runs/2174036019?check_suite_focus=true#step:9:695 (FAILED test/TestSkipInsideYaml.py::test_role_tasks - assert 0 == 1).

But I can resubmit a PR later if wanted.

* master:
  More type (2) (#1497)
  More type (#1496)
  Add ability to ignore jinja2 templates (#1494)
  Fix MetaMainHasInfoRule when running from meta dir (#1493)
Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
@konstruktoid
Copy link
Contributor Author

=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.9.1, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 -- [...]/ansible-lint/.tox/py39-ansible29/bin/python
cachedir: .tox/py39-ansible29/.pytest_cache
rootdir: [...]/ansible-lint, configfile: pytest.ini
plugins: flaky-3.7.0, cov-2.11.1, xdist-2.2.1, forked-1.3.0
collected 314 items / 308 deselected / 6 selected

.tox/py39-ansible29/lib/python3.9/site-packages/ansiblelint/rules/CommandsInsteadOfModulesRule.py::test_apt_get[CommandsInsteadOfModulesRule] PASSED                                                 [ 16%]
.tox/py39-ansible29/lib/python3.9/site-packages/ansiblelint/rules/CommandsInsteadOfModulesRule.py::test_restart_sshd[CommandsInsteadOfModulesRule] PASSED                                            [ 33%]
.tox/py39-ansible29/lib/python3.9/site-packages/ansiblelint/rules/CommandsInsteadOfModulesRule.py::test_git_log[CommandsInsteadOfModulesRule] PASSED                                                 [ 50%]
.tox/py39-ansible29/lib/python3.9/site-packages/ansiblelint/rules/CommandsInsteadOfModulesRule.py::test_git_branch[CommandsInsteadOfModulesRule] PASSED                                              [ 66%]
.tox/py39-ansible29/lib/python3.9/site-packages/ansiblelint/rules/CommandsInsteadOfModulesRule.py::test_systemd_environment[CommandsInsteadOfModulesRule] PASSED                                     [ 83%]
.tox/py39-ansible29/lib/python3.9/site-packages/ansiblelint/rules/CommandsInsteadOfModulesRule.py::test_systemd_runlevel[CommandsInsteadOfModulesRule] PASSED                                        [100%]

----------------------------------------------------- generated xml file: [...]/ansible-lint/.tox/junit.py39-ansible29.xml -----------------------------------------------------
=========================================================================================== slowest 10 durations ===========================================================================================
0.77s call     .tox/py39-ansible29/lib/python3.9/site-packages/ansiblelint/rules/CommandsInsteadOfModulesRule.py::test_apt_get[CommandsInsteadOfModulesRule]
0.68s call     .tox/py39-ansible29/lib/python3.9/site-packages/ansiblelint/rules/CommandsInsteadOfModulesRule.py::test_restart_sshd[CommandsInsteadOfModulesRule]
0.67s call     .tox/py39-ansible29/lib/python3.9/site-packages/ansiblelint/rules/CommandsInsteadOfModulesRule.py::test_git_log[CommandsInsteadOfModulesRule]
0.66s call     .tox/py39-ansible29/lib/python3.9/site-packages/ansiblelint/rules/CommandsInsteadOfModulesRule.py::test_git_branch[CommandsInsteadOfModulesRule]
0.65s call     .tox/py39-ansible29/lib/python3.9/site-packages/ansiblelint/rules/CommandsInsteadOfModulesRule.py::test_systemd_environment[CommandsInsteadOfModulesRule]
0.65s call     .tox/py39-ansible29/lib/python3.9/site-packages/ansiblelint/rules/CommandsInsteadOfModulesRule.py::test_systemd_runlevel[CommandsInsteadOfModulesRule]

(4 durations < 0.005s hidden.  Use -vv to show these durations.)
==================================================================================== 6 passed, 308 deselected in 4.84s =====================================================================================
_________________________________________________________________________________________________ summary __________________________________________________________________________________________________
  py39-ansible29: commands succeeded
  congratulations :)

but tox fails on test/TestSkipInsideYaml.py:94: AssertionError (https://github.com/ansible-community/ansible-lint/pull/1457/checks?check_run_id=2217212759#step:9:681), and I can't really find any relation between the two tests.

Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
* master:
  Recommend using pipx to install ansible-lint (#1520)
  Ignore templated files (#1524)
  src/ansiblelint/utils.py: Ensure that the role file is not a file (#1522)
  Fixed docs edit links (#1525)
  Fix role name handling in prerun.py (#1490)
  More type (3) (#1498)
  Retry prepare environment three times before failing (#1517)
  Add ansible-role-bootstrap (#1503)
  Fix meta-incorrect rule to report correctly (#1515)
  Update dependencies (#1516)
  Add DebOps project to eco test pipeline (#1500)
@ssbarnea
Copy link
Member

ssbarnea commented May 3, 2021

Obsoleted by #1544

@ssbarnea ssbarnea closed this May 3, 2021
@konstruktoid konstruktoid deleted the ISSUE682 branch May 3, 2021 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive for 303 when using command module for setting system runlevel
3 participants