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

'zip' template filter is missing under python3 #28117

Closed
andriilahuta opened this issue Aug 13, 2017 · 1 comment · Fixed by #28158
Closed

'zip' template filter is missing under python3 #28117

andriilahuta opened this issue Aug 13, 2017 · 1 comment · Fixed by #28158
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. c:plugins/action c:plugins/filter python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@andriilahuta
Copy link
Contributor

ISSUE TYPE
  • Bug Report
COMPONENT NAME

zip template filter

ANSIBLE VERSION
ansible 2.3.1.0
  config file = 
  configured module search path = Default w/o overrides
  python version = 3.6.0+ (default, Feb  4 2017, 11:11:33) [GCC 4.9.4]
CONFIGURATION

None

OS / ENVIRONMENT

Ubuntu

SUMMARY

Ansible can't load zip filter under python3. The problem seems to be at this line:

filters['zip'] = itertools.zip

zip is a builtin function in python3 and is not located in itertools

STEPS TO REPRODUCE
ansible -m debug -a "msg={{ [1,2,3]|zip(['a','b','c'])|list }}" all
EXPECTED RESULTS

Output

<hostname> | SUCCESS => {
    "msg": [
        [
            1,
            "a"
        ],
        [
            2,
            "b"
        ],
        [
            3,
            "c"
        ]
    ]
}
ACTUAL RESULTS
<hostname> | FAILED! => {
    "failed": true,
    "msg": "template error while templating string: no filter named 'zip'. String: {{ [1,2,3]|zip(['a','b','c'])|list }}"
}
@ansibot ansibot added affects_2.3 This issue/PR affects Ansible v2.3 bug_report c:plugins/action c:plugins/filter 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 Aug 13, 2017
@alikins alikins removed the needs_triage Needs a first human triage before being processed. label Aug 14, 2017
@andreaso
Copy link
Contributor

Yepp, looks like you are right about the cause.

I have created the #28158 pull request.

andreaso added a commit to andreaso/ansible that referenced this issue Aug 15, 2017
Using the now bundled six library.

Fixes ansible#28117
abadger pushed a commit that referenced this issue Aug 15, 2017
Using the now bundled six library.

Fixes #28117
abadger pushed a commit that referenced this issue Aug 15, 2017
Using the now bundled six library.

Fixes #28117

(cherry picked from commit c9cdc3a)
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.3 This issue/PR affects Ansible v2.3 bug This issue/PR relates to a bug. c:plugins/action c:plugins/filter python3 support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants