You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ ansible --version | grep -E 'version|core'
ansible [core 2.11.4]
python version = 3.8.10 (default, Jun 2 2021, 10:49:15) [GCC 9.4.0]
jinja version = 3.0.1
$ ansible-lint --version
Failed to guess project directory using git:
ansible-lint 5.1.3.dev22 using ansible 2.11.4
$ ansible-lint issue1681*
Failed to guess project directory using git:
WARNING Overriding detected file kind 'yaml' with 'playbook'for given positional argument: issue1681-working.yml
WARNING Overriding detected file kind 'yaml' with 'playbook'for given positional argument: issue1681.yml
WARNING Listing 1 violation(s) that are fatal
syntax-check: Ansible syntax check failed
issue1681.yml:1 [WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'
ERROR! We were unable to read either as JSON nor YAML, these are the errors we got from each:
JSON: Expecting value: line 1 column 1 (char 0)
Syntax Error while loading YAML.
found unacceptable key (unhashable type: 'AnsibleMapping')
The error appears to be in'/tmp/issue1681.yml': line 21, column 16, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
stat:
path: {{ item | quote }}
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
Finished with 1 failure(s), 0 warning(s) on 2 files.
$ diff -uNr issue1681.yml issue1681-working.yml
--- issue1681.yml 2021-09-07 11:28:54.604140602 +0200
+++ issue1681-working.yml 2021-09-07 11:28:27.504140867 +0200
@@ -18,7 +18,7 @@
- name: stat quote path
stat:
- path: {{ item | quote }}
+ path: "{{ item | quote }}"
with_items:
- "/tmp/aaa"
...
$ ansible-lint --version
ansible-lint 5.1.3.dev22 using ansible 2.11.4
$ cat /tmp/issue1681.yml
---
- hosts: all
tasks:
- name: command without quotes
ansible.builtin.command: cat {{ myfile|quote }}
register: myoutput
changed_when: myoutput.rc != 0
- name: command should fail
ansible.builtin.command: cat {{ myfile|quote }}
...
$ ansible-lint /tmp/issue1681.yml
Loading custom .yamllint config file, this extends our internal yamllint config.
WARNING Overriding detected file kind 'yaml' with 'playbook'for given positional argument: /tmp/issue1681.yml
WARNING Listing 1 violation(s) that are fatal
no-changed-when: Commands should not change things if nothing needs doing
../../../../tmp/issue1681.yml:9 Task/Handler: command should fail
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
- no-changed-when # Commands should not change things if nothing needs doing
Finished with 1 failure(s), 0 warning(s) on 1 files.
$
https://github.com/ansible/ansible/blob/devel/lib/ansible/errors/__init__.py#L165-L166
Originally posted by @konstruktoid in #1706 (comment)
The text was updated successfully, but these errors were encountered: