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

25 lines
596 B
YAML

---
- 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