-
Notifications
You must be signed in to change notification settings - Fork 857
fix ''dict object has no attribute dict_keys" issue with python3 #578
Conversation
In Python2, the dict.keys(), dict.values(), and dict.items() methods returns a list. Jinja2 returns that to Ansible via a string representation that Ansible can turn back into a list. In Python3, those methods return a dictionary view object. resource: https://docs.ansible.com/ansible/2.4/playbooks_python_version.html#dictionary-views
@@ -1,6 +1,6 @@ | |||
--- | |||
- name: set fact manage_file_users | |||
set_fact: manage_file_users=es_users is defined and es_users.file is defined and es_users.file.keys() | length > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are some of these now .keys() | list
while others are just list
with the .keys()
also removed? I can't figure out why some still need .keys()
and some don't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a mistake => fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were a few more were it was removed. Which is why I thought it was on purpose. At least 2 more in this PR where it was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure? I don't see no more | list
without .keys()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks! Quick turn-around! |
In Python2, the dict.keys(), dict.values(), and dict.items() methods returns a list. Jinja2 returns that to Ansible via a string representation that Ansible can turn back into a list. In Python3, those methods return a dictionary view object.
resource: https://docs.ansible.com/ansible/2.4/playbooks_python_version.html#dictionary-views
Fix #570