-
Notifications
You must be signed in to change notification settings - Fork 23.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add jinja2 groupby filter override to cast namedtuple to tuple. Fixes #…
- Loading branch information
Showing
5 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
posix/ci/group2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
MYTMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir') | ||
|
||
if [ -f /usr/bin/python3 ] | ||
then | ||
PYTHON="--python /usr/bin/python3" | ||
else | ||
PYTHON="" | ||
fi | ||
|
||
virtualenv --system-site-packages $PYTHON "${MYTMPDIR}/jinja2" | ||
|
||
source "${MYTMPDIR}/jinja2/bin/activate" | ||
|
||
pip install -U jinja2==2.9.4 | ||
|
||
ansible-playbook -i ../../inventory test_jinja2_groupby.yml -v | ||
|
||
pip install -U "jinja2<2.9.0" | ||
|
||
ansible-playbook -i ../../inventory test_jinja2_groupby.yml -v | ||
|
||
deactivate | ||
|
||
rm -r "${MYTMPDIR}" |
24 changes: 24 additions & 0 deletions
24
test/integration/targets/groupby_filter/test_jinja2_groupby.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
- name: Test jinja2 groupby | ||
hosts: localhost | ||
gather_facts: False | ||
connection: local | ||
vars: | ||
fruits: | ||
- name: apple | ||
enjoy: yes | ||
- name: orange | ||
enjoy: no | ||
- name: strawberry | ||
enjoy: yes | ||
expected: [[false, [{"enjoy": false, "name": "orange"}]], [true, [{"enjoy": true, "name": "apple"}, {"enjoy": true, "name": "strawberry"}]]] | ||
tasks: | ||
- debug: | ||
msg: "{{ lookup('pipe', 'pip freeze | grep -i jinja2') }}" | ||
|
||
- set_fact: | ||
result: "{{ fruits | groupby('enjoy') }}" | ||
|
||
- assert: | ||
that: | ||
- result == expected |