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

include_tasks with lookup causes "TypeError: argument of type 'NoneType' is not iterable" #2875

Closed
richm opened this issue Jan 9, 2023 · 0 comments · Fixed by #2974
Closed
Assignees
Labels

Comments

@richm
Copy link

richm commented Jan 9, 2023

Summary
>ansible-lint --version
ansible-lint 6.10.2 using ansible 2.14.1

The following code in tasks/junk.yml:

- name: Perform platform/version specific tasks
  include_tasks: "{{ lookup('first_found', __ff_params) }}"
  vars:
    __ff_params:
      files:
        - "{{ ansible_facts['distribution'] ~ '_' ~
              ansible_facts['distribution_version'] }}.yml"
        - "{{ ansible_facts['distribution'] ~ '_' ~
              ansible_facts['distribution_major_version'] }}.yml"
        - "{{ ansible_facts['distribution'] }}.yml"
        - "{{ ansible_facts['os_family'] }}.yml"
        - "default.yml"
      paths:
        - "{{ role_path }}/tasks/setup"

then run ansible-lint -vv gives the following error:

Traceback (most recent call last):
  File "/home/rmeggins/.ansible-lint/bin/ansible-lint", line 8, in <module>
    sys.exit(_run_cli_entrypoint())
  File "/home/rmeggins/.ansible-lint/lib64/python3.10/site-packages/ansiblelint/__main__.py", line 344, in _run_cli_entrypoint
    sys.exit(main(sys.argv))
  File "/home/rmeggins/.ansible-lint/lib64/python3.10/site-packages/ansiblelint/__main__.py", line 242, in main
    result = _get_matches(rules, options)
  File "/home/rmeggins/.ansible-lint/lib64/python3.10/site-packages/ansiblelint/runner.py", line 235, in _get_matches
    matches.extend(runner.run())
  File "/home/rmeggins/.ansible-lint/lib64/python3.10/site-packages/ansiblelint/runner.py", line 166, in run
    matches.extend(self._emit_matches(files))
  File "/home/rmeggins/.ansible-lint/lib64/python3.10/site-packages/ansiblelint/runner.py", line 204, in _emit_matches
    for child in ansiblelint.utils.find_children(lintable):
  File "/home/rmeggins/.ansible-lint/lib64/python3.10/site-packages/ansiblelint/utils.py", line 226, in find_children
    for child in play_children(basedir, item, lintable.kind, playbook_dir):
  File "/home/rmeggins/.ansible-lint/lib64/python3.10/site-packages/ansiblelint/utils.py", line 306, in play_children
    return delegate_map[k](basedir, k, v, parent_type)
  File "/home/rmeggins/.ansible-lint/lib64/python3.10/site-packages/ansiblelint/utils.py", line 318, in _include_children
    if "{{" in v:  # pragma: no branch
TypeError: argument of type 'NoneType' is not iterable

The problem is that the code uses disable_lookups=True for some reason, so the output of the template evaluation v is None. Not sure what to do here - perhaps a special case for _include_children when v is None?

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 6.10.2 using ansible 2.14.1
  • ansible installation method: one of source, pip, OS package
  • ansible-lint installation method: one of source, pip, OS package
STEPS TO REPRODUCE
Desired Behavior

Possible security bugs should be reported via email to security@ansible.com

Actual Behavior

Please give some details of what is happening.
Include a minimum complete verifiable example with:

  • minimized playbook to reproduce the error
  • the output of running ansible-lint including the command line used
  • if you're getting a stack trace, also the output of
    ansible-playbook --syntax-check playbook

@richm richm added bug new Triage required labels Jan 9, 2023
richm added a commit to richm/linux-system-roles-pam_pwd that referenced this issue Jan 11, 2023
ansible-lint is broken with this code - ansible/ansible-lint#2875
@ssbarnea ssbarnea closed this as completed Feb 2, 2023
@ssbarnea ssbarnea reopened this Feb 2, 2023
ssbarnea added a commit that referenced this issue Feb 2, 2023
ssbarnea added a commit that referenced this issue Feb 2, 2023
@ssbarnea ssbarnea removed the new Triage required label Feb 2, 2023
@ssbarnea ssbarnea self-assigned this Feb 2, 2023
ssbarnea added a commit that referenced this issue Feb 2, 2023
ssbarnea added a commit that referenced this issue Feb 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants