mschuchard/linter-ansible-linting

Build failed - Package doesn't work correctly

Alucard616 opened this issue · 14 comments

Hi there!
I just wanted to try out this package with my atom-editor, but unfortunately, it doesn't work at all. Nothing is shown, if there are any errors.
I installed the dependencies "linter" and "language-ansible", but i do not get any errors.

So I looked here, if theres anything know and saw, that the build is failing.
After that, I checked, if e.g. "linter-yaml" is working. It does.

I really hope, this could be fixed :)

Regards
Patrick

I would need more information about your environment to assist with debugging why your setup is not working.

I'm working on a Fedora 34 Workstation and my Atom Version is 1.57.0
What information do you also need? I'm a lil' bit lost, sorry.

Versions of ansible-lint and ansible would be the most relevant here.

oh, sure, sorry.

here you go:
pip show ansible-lint
Name: ansible-lint
Version: 5.0.12

and ansible's version?

Also the package has been acceptance tested as valid against ansible-lint 3.5-5.0.12 and ansible 2.0-2.11 on Linux, so you are probably going to need to do some heavier debugging on your end to find the edge case here that may not be covered yet.

If Atom throws an error during linting, then that would also be helpful.

In our deployment, we use ansible 2.10.10

i have installed ansible 2.9.23 but don't use it.
When i call "ansible" in my console, a script + a docker container is triggered.

I see no error in Atom.
It's just, that nothing happens.

Ok at this point I need a MCVE. If I can reproduce the issue, then I will be able to begin hunting down the cause. If I cannot, then you will need to troubleshoot your environment setup (probably with others at technical assistance resource sites). If you can determine what in your environment is causing this issue and you cannot rectify it yourself with the tools provided in your OS/Atom/Ansible-Lint/Linter-Ansible-Linting etc., then I will need to expand the code to cover your setup.

OK
I hope, this helps you, to reproduce it.
First:
I deleted all my aliases regarding to ansible, to make sure, this is not the problem.
It's still the same after that.

Sooo
I'm working on a Fedora Workstation 34
Ansible is installed via dnf source in version 2.9.23
After that I installed ansible-lint (with yamllint) via pip3 with: pip3 install "ansible-lint[yamllint]"
Version is ansible-lint 5.0.12 using ansible 2.9.23

I opened the atom editor, go to the settings and search for the linter-ansible-linter package and install it.
Then I install the dependencies: linter and language-ansible.
After these two additional packages are also installed, i restart atom, so linter can get some more packages

After that, linter is ready

I'll open some yml-file in my ansible project and there is nothing shown in linter.
I'll recheck with ansible-linter from my console, where i see some issues.

I see no error message, that linter-ansible isn't working or something. Just nothing happens.
When I install the yamllint package after that, i see the yamllint errors within the linter.

my yml example is:

---
  - name: some shell command
    shell: echo bong

ansible-lint should give me the errors, that the indentation isn't correct + shell should not be used with a single command

As an isolated task list, that file yields the following display with Linter-Ansible-Linting, Ansible-Lint 5.0.12, and Ansible 2.11.2 on Linux:

Error Ansible-Lint syntax-check: 'shell' is not a valid attribute for a Play 2:5 null/foo.yml

which evinces the interesting point that ansible-lint expects to only lint roles or playbooks, so an isolated task list has a null type for the project when linting an isolated task list, which gives me an interetsting TODO out of this. It also is the expected output because that is a syntax issue on 2.11.2. I am unsure what the output should be with Ansible 2.9.23, but probably something about not using the shell module when command would suffice.

Interestingly enough, if I fix the module to be ansible.builtin.shell then Ansible-Lint still throws the same error, which points at a bug in Ansible-Lint.

ERROR! 'ansible.builtin.shell' is not a valid attribute for a Play

The error appears to be in '/home/matt/foo.yml': line 2, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


  • name: some shell command
    ^ here

Both of these issues are just coincidental though, and the takeaway is you will indeed need to debug your environment setup to proceed further. This is unless Ansible-Lint with that version of Ansible would lint clean on that file, in which case the MCVE is invalid.

Aahh, good to know.

I put an extra yml in some of my role tasks and tested it there.
Sorry, for not telling.

When I use ansible-lint with my console there, I get this message:

WARNING  Listing 3 violation(s) that are fatal
test.yml:2: command-instead-of-shell Use shell only when shell functionality is required
test.yml:2: no-changed-when Commands should not change things if nothing needs doing
test.yml:2: yaml wrong indentation: expected 0 but found 2 (indentation)

Interestingly, after I started Atom today, I got, for the first time, an error from ansible-lint:

[Linter] Error running Ansible-Lint Error: Failed to spawn command ~/.local/bin/ansible-lint. Make sure ~/.local/bin/ansible-lint is installed and on your PATH

When I check on my console, it is found:

whereis ansible-lint 
ansible-lint: /home/alucard616/.local/bin/ansible-lint

That error is thrown from sb-exec, which linter packages rely on for spawning shell processes. It would be the usual debugging around pathing, permissions, etc. Note also that just because your user in your shell environment has access to that path does not mean Atom does also, since those two processes can be spawned with different environments.

Hi there!

I checked my atom PATH:

process.env.PATH
"/home/myuser/.local/bin:/home/myuser/bin:/home/myuser/.local/bin:/home/myuser/bin:/usr/lib64/qt-3.3/bin:/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin"

This seems correct to me, so I don't really know, where this error comes from.

Anyways. I changed the executable path in the ansible-linter to an absolute path.

Sadly, I'm back at: nothing happens.

Again I created a new file in my ansible-project:

ansible
-> roles
---> some_role
-----> tasks
-------> test.yml

same example:

---
  - name: some shell command
    shell: echo bong
ansible-lint -p test.yml 
WARNING  Listing 3 violation(s) that are fatal
test.yml:2: command-instead-of-shell Use shell only when shell functionality is required
test.yml:2: no-changed-when Commands should not change things if nothing needs doing
test.yml:2: yaml wrong indentation: expected 0 but found 2 (indentation)

and in atom, there is nothing, sadly

Any news?

For me it don't work - no errors or warnings are visible in Atom - Linter Warnings:

ansible --version
ansible [core 2.12.2]
  config file = /home/$USER/git/myproject/ansible.cfg
  configured module search path = ['/home/$USER/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/$USER/git/myproject/venv/lib/python3.8/site-packages/ansible
  ansible collection location = /home/$USER/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/$USER/git/myproject/venv/bin/ansible
  python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
  jinja version = 2.11.3
  libyaml = True
ansible-lint --version
ansible-lint 5.3.2 using ansible 2.12.2
atom --version
Atom    : 1.59.0
Electron: 9.4.4
Chrome  : 83.0.4103.122
Node    : 12.14.1

config:

  "linter-ansible-linting":
    ansibleLintExecutablePath: "/home/$USER/git/myproject/venv/bin/ansible-lint"
    displaySeverity: true
    useProjectConfig: true
  "linter-pylint":
    executablePath: "%p/venv/bin/pylint"
    pythonPath: "%p/venv/bin/python"
  "linter-ui-default":
    panelHeight: 257
  "linter-yaml":
    useProjectConfig: ".yamllint"
    yamlLintExecutablePath: "/home/$USER/git/myproject/venv/bin/yamllint"

ansible-lint on command line:

(venv) ansible-lint roles/myrole/tasks/main.yml

WARNING  Listing 1 violation(s) that are fatal
unnamed-task: All tasks should be named
roles/myrole/tasks/main.yml:2 Task/Handler: import_role name=myrole2 tasks_from=taks2

You can skip specific rules or tags by adding them to your configuration file:
# .ansible-lint
warn_list:  # or 'skip_list' to silence them completely
  - unnamed-task  # All tasks should be named

Finished with 1 failure(s), 0 warning(s) on 1 files.

If you need assistance with your personal environment compatibility with Atom and Atom packages, then you should either open a new issue or check with available support channels/groups/etc. Thanks!