mirror of https://github.com/ansible/ansible.git
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.
25 lines
596 B
YAML
25 lines
596 B
YAML
![]()
8 years ago
|
---
|
||
|
- 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
|