|
|
@ -42,7 +42,8 @@ for example::
|
|
|
|
- shell: cat /some/path/to/file.json
|
|
|
|
- shell: cat /some/path/to/file.json
|
|
|
|
register: result
|
|
|
|
register: result
|
|
|
|
|
|
|
|
|
|
|
|
- set_fact: myvar="{{ result.stdout | from_json }}"
|
|
|
|
- set_fact:
|
|
|
|
|
|
|
|
myvar: "{{ result.stdout | from_json }}"
|
|
|
|
|
|
|
|
|
|
|
|
.. _forcing_variables_to_be_defined:
|
|
|
|
.. _forcing_variables_to_be_defined:
|
|
|
|
|
|
|
|
|
|
|
@ -316,7 +317,8 @@ Or, alternatively::
|
|
|
|
In this example, we get a hash map with all ports and names of a cluster::
|
|
|
|
In this example, we get a hash map with all ports and names of a cluster::
|
|
|
|
|
|
|
|
|
|
|
|
- name: "Display all server ports and names from cluster1"
|
|
|
|
- name: "Display all server ports and names from cluster1"
|
|
|
|
debug: var=item
|
|
|
|
debug:
|
|
|
|
|
|
|
|
var: item
|
|
|
|
loop: "{{domain_definition|json_query(server_name_cluster1_query)}}"
|
|
|
|
loop: "{{domain_definition|json_query(server_name_cluster1_query)}}"
|
|
|
|
vars:
|
|
|
|
vars:
|
|
|
|
server_name_cluster1_query: "domain.server[?cluster=='cluster2'].{name: name, port: port}"
|
|
|
|
server_name_cluster1_query: "domain.server[?cluster=='cluster2'].{name: name, port: port}"
|
|
|
@ -891,7 +893,8 @@ To create a UUID from a string (new in version 1.9)::
|
|
|
|
To cast values as certain types, such as when you input a string as "True" from a vars_prompt and the system
|
|
|
|
To cast values as certain types, such as when you input a string as "True" from a vars_prompt and the system
|
|
|
|
doesn't know it is a boolean value::
|
|
|
|
doesn't know it is a boolean value::
|
|
|
|
|
|
|
|
|
|
|
|
- debug: msg=test
|
|
|
|
- debug:
|
|
|
|
|
|
|
|
msg: test
|
|
|
|
when: some_string_value | bool
|
|
|
|
when: some_string_value | bool
|
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 1.6
|
|
|
|
.. versionadded:: 1.6
|
|
|
@ -916,29 +919,35 @@ This set of filters returns a list of combined lists.
|
|
|
|
To get permutations of a list::
|
|
|
|
To get permutations of a list::
|
|
|
|
|
|
|
|
|
|
|
|
- name: give me largest permutations (order matters)
|
|
|
|
- name: give me largest permutations (order matters)
|
|
|
|
debug: msg="{{ [1,2,3,4,5]|permutations|list }}"
|
|
|
|
debug:
|
|
|
|
|
|
|
|
msg: "{{ [1,2,3,4,5]|permutations|list }}"
|
|
|
|
|
|
|
|
|
|
|
|
- name: give me permutations of sets of three
|
|
|
|
- name: give me permutations of sets of three
|
|
|
|
debug: msg="{{ [1,2,3,4,5]|permutations(3)|list }}"
|
|
|
|
debug:
|
|
|
|
|
|
|
|
msg: "{{ [1,2,3,4,5]|permutations(3)|list }}"
|
|
|
|
|
|
|
|
|
|
|
|
Combinations always require a set size::
|
|
|
|
Combinations always require a set size::
|
|
|
|
|
|
|
|
|
|
|
|
- name: give me combinations for sets of two
|
|
|
|
- name: give me combinations for sets of two
|
|
|
|
debug: msg="{{ [1,2,3,4,5]|combinations(2)|list }}"
|
|
|
|
debug:
|
|
|
|
|
|
|
|
msg: "{{ [1,2,3,4,5]|combinations(2)|list }}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
To get a list combining the elements of other lists use ``zip``::
|
|
|
|
To get a list combining the elements of other lists use ``zip``::
|
|
|
|
|
|
|
|
|
|
|
|
- name: give me list combo of two lists
|
|
|
|
- name: give me list combo of two lists
|
|
|
|
debug: msg="{{ [1,2,3,4,5]|zip(['a','b','c','d','e','f'])|list }}"
|
|
|
|
debug:
|
|
|
|
|
|
|
|
msg: "{{ [1,2,3,4,5]|zip(['a','b','c','d','e','f'])|list }}"
|
|
|
|
|
|
|
|
|
|
|
|
- name: give me shortest combo of two lists
|
|
|
|
- name: give me shortest combo of two lists
|
|
|
|
debug: msg="{{ [1,2,3]|zip(['a','b','c','d','e','f'])|list }}"
|
|
|
|
debug:
|
|
|
|
|
|
|
|
msg: "{{ [1,2,3]|zip(['a','b','c','d','e','f'])|list }}"
|
|
|
|
|
|
|
|
|
|
|
|
To always exhaust all list use ``zip_longest``::
|
|
|
|
To always exhaust all list use ``zip_longest``::
|
|
|
|
|
|
|
|
|
|
|
|
- name: give me longest combo of three lists , fill with X
|
|
|
|
- name: give me longest combo of three lists , fill with X
|
|
|
|
debug: msg="{{ [1,2,3]|zip_longest(['a','b','c','d','e','f'], [21, 22, 23], fillvalue='X')|list }}"
|
|
|
|
debug:
|
|
|
|
|
|
|
|
msg: "{{ [1,2,3]|zip_longest(['a','b','c','d','e','f'], [21, 22, 23], fillvalue='X')|list }}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.. versionadded:: 2.4
|
|
|
|
.. versionadded:: 2.4
|
|
|
|