Last active
December 30, 2019 14:04
-
-
Save ssato/6701565f4977828e25db4962457194d6 to your computer and use it in GitHub Desktop.
Another answer for https://qiita.com/masa2223/items/ed9717770c81d3693c39
This file contains hidden or 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
- name: Jinja 2 filter example | |
hosts: localhost | |
gather_facts: no | |
vars: | |
ansible_python_interpreter: /usr/bin/python3 | |
input_dics: | |
- type: a | |
name: router1 | |
- type: b | |
name: router2 | |
- type: c | |
name: router3 | |
selector: ac | |
tasks: | |
- name: Select dicts by selector | |
debug: | |
msg: >- | |
{{ input_dics | selectattr("type", "in", selector) | |
| map(attribute='name') | |
| list }} | |
# vim:sw=2:ts=2:et: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment