You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/integration/targets/groupby_filter/test_jinja2_groupby.yml

30 lines
786 B
YAML

---
- name: Test jinja2 groupby
hosts: localhost
gather_facts: True
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:
- name: show python interpreter
debug:
msg: "{{ ansible_python['executable'] }}"
- name: show jinja2 version
debug:
msg: "{{ lookup('pipe', '{{ ansible_python[\"executable\"] }} -c \"import jinja2; print(jinja2.__version__)\"') }}"
- set_fact:
result: "{{ fruits | groupby('enjoy') }}"
- assert:
that:
- result == expected