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
After updating ansible-lint from 5.x to 6.9.0 I am facing a ton of issues. These are just a small part of them but the most obvious ones.
One of these is several WARNING lines about exception from JinjaRule as in:
WARNING Ignored exception from JinjaRule.<bound method AnsibleLintRule.matchtasks of jinja: Rule that looks inside jinja2 templates.> while processing roles/rolea/tasks/main.yml (tasks): local variable 'result' referenced before assignment
WARNING Ignored exception from JinjaRule.<bound method AnsibleLintRule.matchtasks of jinja: Rule that looks inside jinja2 templates.> while processing roles/roleb/tasks/main.yml (tasks): 'KeyError' object has no attribute 'message'
WARNING Ignored exception from JinjaRule.<bound method AnsibleLintRule.matchtasks of jinja: Rule that looks inside jinja2 templates.> while processing roles/rolec/tasks/main.yml (tasks): local variable 'result' referenced before assignment
WARNING Ignored exception from JinjaRule.<bound method AnsibleLintRule.matchtasks of jinja: Rule that looks inside jinja2 templates.> while processing roles/roled/tasks/main.yml (tasks): local variable 'result' referenced before assignment
Are these something I should be concerned about? The listed variables like result or message is not something that is used in those roles, they seem to refer to some variables of ansible-lint and not my role?
Secondly there is jinja[invalid] on one line which is a bit complex but nothing really special and works flawlessly when running the task:
jinja[invalid]: An unhandled exception occurred while templating '{{ 'host' ~ ('-nodeB' if addrv4 | ansible.utils.ipaddr('192.0.2.0/26') == addrv4 else '') ~ '.domain.' ~ tld }}'. Error was a <class 'ansible.errors.AnsibleFilterError'>, original message: Unrecognized type <<class 'ansible.template.AnsibleUndefined'>> for ipaddr filter <value>
roles/server/tasks/main.yml:2 Task/Handler: Set site address
The tasks file of the role that triggers the exception works flawlessly when run, reduced to only this single task gives the exception:
---
- name: Set site address
ansible.builtin.set_fact:
siteaddress: "{{ website }}"
vars:
website: "{{ 'host' ~ ('-nodeB' if addrv4 |
ansible.utils.ipaddr('192.0.2.0/26') == addrv4 else '') ~ '.domain.' ~ tld }}"
It seems like a bug in ansible-lint since it works just fine when run?
And thirdly there is a traceback that stops ansible-lint in role task file that is reduced to simply:
---
- name: Ignore in check modewhen:
- not ansible_check_mode | bool
- not skip_tasks | default('false') | boolblock:
- name: failed at splittingansible.builtin.include_tasks:
file: "{{ role_path ~ '/../../../' ~ handler_path }}"
The traceback:
Traceback (most recent call last):
File "/ansible/bin/ansible-lint", line 8, in <module>
sys.exit(_run_cli_entrypoint())
File "/ansible/lib64/python3.9/site-packages/ansiblelint/__main__.py", line 328, in _run_cli_entrypoint
sys.exit(main(sys.argv))
File "/ansible/lib64/python3.9/site-packages/ansiblelint/__main__.py", line 226, in main
result = _get_matches(rules, options)
File "/ansible/lib64/python3.9/site-packages/ansiblelint/runner.py", line 235, in _get_matches
matches.extend(runner.run())
File "/ansible/lib64/python3.9/site-packages/ansiblelint/runner.py", line 166, in run
matches.extend(self._emit_matches(files))
File "/ansible/lib64/python3.9/site-packages/ansiblelint/runner.py", line 204, in _emit_matches
for child in ansiblelint.utils.find_children(lintable):
File "/ansible/lib64/python3.9/site-packages/ansiblelint/utils.py", line 227, in find_children
for token in split_args(path_str):
File "/ansible/lib64/python3.9/site-packages/ansible/parsing/splitter.py", line 284, in split_args
raise AnsibleParserError(u"failed at splitting arguments, either an unbalanced jinja2 block or quotes: {0}".format(args))
ansible.errors.AnsibleParserError: failed at splitting arguments, either an unbalanced jinja2 block or quotes: /home/' ~ handler_path }}
This also works when run with the requisite var passed to the role so it also looks like a bug somewhere?
The content of role_path and the path in the last line of output, /home/ also looks suspicious. The real role_path should have 2 more directories and not just /home/:
ansible-lint is run from /home/ansible/site.
The location of the tasks file that is being run is in role /home/ansible/site/roles/server/apache (normal content of role_path when run in ansible-playbook), /home/ansible/site/roles/server/apache/tasks/main.yml.
Then adding /../../../ should result in /home/ansible/site/ and not just /home/.
The variable handler_path contains something like roles/server/apache/tasks/taskfile.yml, and the result of the task would be a path to a valid tasks file.
I could not say if any of that matters or not?
And why am I doing all that ugliness? Due to various extremely disappointing limitations in ansible and code modularity, it is a workaround for import_role not usable in various cases, and is the only way to accomplish.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
After updating ansible-lint from 5.x to 6.9.0 I am facing a ton of issues. These are just a small part of them but the most obvious ones.
One of these is several
WARNING
lines aboutexception from JinjaRule
as in:Are these something I should be concerned about? The listed variables like
result
ormessage
is not something that is used in those roles, they seem to refer to some variables of ansible-lint and not my role?Secondly there is
jinja[invalid]
on one line which is a bit complex but nothing really special and works flawlessly when running the task:The tasks file of the role that triggers the exception works flawlessly when run, reduced to only this single task gives the exception:
It seems like a bug in ansible-lint since it works just fine when run?
And thirdly there is a traceback that stops ansible-lint in role task file that is reduced to simply:
The traceback:
This also works when run with the requisite var passed to the role so it also looks like a bug somewhere?
The content of
role_path
and the path in the last line of output,/home/
also looks suspicious. The realrole_path
should have 2 more directories and not just/home/
:ansible-lint
is run from/home/ansible/site
./home/ansible/site/roles/server/apache
(normal content ofrole_path
when run inansible-playbook
),/home/ansible/site/roles/server/apache/tasks/main.yml
./../../../
should result in/home/ansible/site/
and not just/home/
.handler_path
contains something likeroles/server/apache/tasks/taskfile.yml
, and the result of the task would be a path to a valid tasks file.I could not say if any of that matters or not?
And why am I doing all that ugliness? Due to various extremely disappointing limitations in ansible and code modularity, it is a workaround for
import_role
not usable in various cases, and is the only way to accomplish.Beta Was this translation helpful? Give feedback.
All reactions