Last active
May 27, 2020 09:29
-
-
Save dudebowski/4372f9947018060fa6f527a7bddc096d to your computer and use it in GitHub Desktop.
select one item from listand put it in a fact
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: select | |
| gather_facts: false | |
| hosts: localhost | |
| connection: local | |
| vars: | |
| - my_selector: | |
| - "the_value_to_select" | |
| tasks: | |
| - name: use it | |
| debug: | |
| msg: "{{ first_user }}" | |
| - name: put it in a fact | |
| set_fact: | |
| my_fact: "{{ the_list| selectattr('attribute_name', 'match', lookup('vars', myvar) | first) | first }}" | |
| vars: | |
| my_var: selector |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment