Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Make template compatible with both Python 2 and 3 #35

Merged
merged 1 commit into from
Apr 13, 2018

Conversation

nikosgraser
Copy link
Contributor

When using this role in an environment where the default python
interpreter is python3, the ansible run fails when jinja2 tries to
process templates/alertmanager.yml.j2.

This is because in Python 3, dict objects no longer have the
.iteritems() method (see e.g.: https://wiki.python.org/moin/Python3.0,
under "Built-in Changes").

For the purposes it's used in the template, .items() is functionally
equivalent to .iteritems() except that it also works in Python 3.

Also, the implementation for looping over dictionary k/v pairs is now
consistent over both template files used in this role.

When using this role in an environment where the default python
interpreter is python3, the ansible run fails when jinja2 tries to
process `templates/alertmanager.yml.j2`.

This is because in Python 3, `dict` objects no longer have the
`.iteritems()` method (see e.g.: https://wiki.python.org/moin/Python3.0,
under "Built-in Changes").

For the purposes it's used in the template, `.items()` is functionally
equivalent to `.iteritems()` except that it also works in Python 3.
@paulfantom
Copy link
Member

Thanks! 👍

@lock
Copy link

lock bot commented Mar 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants