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

recent change in Jinja breaks existing playbooks with jinja2_native=true #69196

Closed
Jean-Daniel opened this issue Apr 27, 2020 · 3 comments
Closed
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. files Files category module This issue/PR relates to a module. native_jinja issues related to jinja native types python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@Jean-Daniel
Copy link

SUMMARY

I have a simple playbook and since a released change in Jinja2 (2.11.2), my playbook now fails with error:

fatal: [localhost]: FAILED! => {"msg": "Invalid data passed to 'loop', it requires a list, got this instead: [('dsa', ''), ('dsa', '.pub'), ('rsa', ''), ('rsa', '.pub'), ('ecdsa', ''), ('ecdsa', '.pub'), ('ed25519', ''), ('ed25519', '.pub')]. Hint: If you passed a list/dict of just one element, try adding wantlist=True to your lookup invocation or use q/query instead of lookup."}
ISSUE TYPE
  • Bug Report
COMPONENT NAME

template

ANSIBLE VERSION
ansible 2.9.7
  config file = /Users/jddupas/Desktop/ansible/ansible.cfg
  configured module search path = ['/Users/jddupas/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/jddupas/Desktop/ansible/.venv/lib/python3.7/site-packages/ansible
  executable location = /Users/jddupas/Desktop/ansible/.venv/bin/ansible
  python version = 3.7.7 (default, Apr 18 2020, 15:06:20) [Clang 11.0.3 (clang-1103.0.32.59)]
CONFIGURATION
DEFAULT_JINJA2_NATIVE(/Users/jddupas/Desktop/ansible/ansible.cfg) = True
OS / ENVIRONMENT

Tested on macOS and Linux, with bare minimal inventory.

STEPS TO REPRODUCE

Run the following playbook (make sure you enable jinja2_native template).

- hosts: localhost
  tasks:
    - loop: "{{ [ 'dsa', 'rsa', 'ecdsa', 'ed25519' ] | product([ '', '.pub' ]) | list }}"
      debug:
        msg: "{{ item }}"
EXPECTED RESULTS

With Jinja 2.11.1, it work fine, with Jinja 2.11.2, it breaks with the error mentioned above.

ACTUAL RESULTS
TASK [debug] ***************************************************************************************************************************************************************************************************************
task path: loop.yaml:4
fatal: [localhost]: FAILED! => {
    "msg": "Invalid data passed to 'loop', it requires a list, got this instead: [('dsa', ''), ('dsa', '.pub'), ('rsa', ''), ('rsa', '.pub'), ('ecdsa', ''), ('ecdsa', '.pub'), ('ed25519', ''), ('ed25519', '.pub')]. Hint: If you passed a list/dict of just one element, try adding wantlist=True to your lookup invocation or use q/query instead of lookup."
}

@ansibot
Copy link
Contributor

ansibot commented Apr 27, 2020

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. files Files category module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Apr 27, 2020
@mkrizek
Copy link
Contributor

mkrizek commented Apr 27, 2020

So like I mentioned in pallets/jinja#1186 I cannot reproduce this with the devel branch. This does happen on 2.9. It has been fixed in #68938. The backport for 2.9 is opened in #69044.

So until the fix is backported, you can either downgrade Jinja2 or use Ansible's devel branch. I will leave this open until the fix is released.

Thanks!

@mkrizek mkrizek added native_jinja issues related to jinja native types and removed needs_triage Needs a first human triage before being processed. labels Apr 27, 2020
@mkrizek
Copy link
Contributor

mkrizek commented May 6, 2020

I am going to go ahead and close this as the fix for this issue has been backported and will be included in the 2.9.8 release.

@mkrizek mkrizek closed this as completed May 6, 2020
@ansible ansible locked and limited conversation to collaborators Jun 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 bug This issue/PR relates to a bug. files Files category module This issue/PR relates to a module. native_jinja issues related to jinja native types python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

No branches or pull requests

3 participants