This repository has been archived by the owner on Mar 6, 2023. It is now read-only.
Make node_exporter.service template compatible with both Python 2 and 3 #33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using this role in an environment where the default python
interpreter is python3, the ansible run fails when jinja2 tries to
process
templates/node_exporter.service.j2
.This is because in Python 3,
dict.items()
returns a view objectwhich can't be indexed directly (in Python 2, this returns a list).
Casting the result of
c.items()
explicitly to a list allows indexingunder Python 3 while not changing the outcome in Python 2.
When executed in a Python 3 environment, the order
in which the items are looped over might be different since "Keys and
values are listed in an arbitrary order which is non-random, varies
across Python implementations, and depends on the dictionary’s history
of insertions and deletions."
(https://docs.python.org/3.6/library/stdtypes.html#dict-views)
Otherwise, this change is functionally identical.