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.
89 lines
2.0 KiB
YAML
89 lines
2.0 KiB
YAML
- name: add two ints
|
|
set_fact:
|
|
integer_sum: "{{ i_one + i_two }}"
|
|
|
|
- assert:
|
|
that:
|
|
- 'integer_sum == 3'
|
|
- 'integer_sum|type_debug == "int"'
|
|
|
|
- name: add casted string and int
|
|
set_fact:
|
|
integer_sum2: "{{ s_one|int + i_two }}"
|
|
|
|
- assert:
|
|
that:
|
|
- 'integer_sum2 == 3'
|
|
- 'integer_sum2|type_debug == "int"'
|
|
|
|
- name: concatenate int and string
|
|
set_fact:
|
|
string_sum: "{{ [(i_one|to_text), s_two]|join('') }}"
|
|
|
|
- assert:
|
|
that:
|
|
- 'string_sum == "12"'
|
|
- 'string_sum|type_debug in ["str", "unicode"]'
|
|
|
|
- name: add two lists
|
|
set_fact:
|
|
list_sum: "{{ list_one + list_two }}"
|
|
|
|
- assert:
|
|
that:
|
|
- 'list_sum == ["one", "two", "three", "four"]'
|
|
- 'list_sum|type_debug == "list"'
|
|
|
|
- name: add two lists, multi expression
|
|
set_fact:
|
|
list_sum_multi: "{{ list_one }} + {{ list_two }}"
|
|
|
|
- assert:
|
|
that:
|
|
- 'list_sum_multi|type_debug in ["str", "unicode"]'
|
|
|
|
- name: add two dicts
|
|
set_fact:
|
|
dict_sum: "{{ dict_one + dict_two }}"
|
|
ignore_errors: yes
|
|
|
|
- assert:
|
|
that:
|
|
- 'dict_sum is undefined'
|
|
|
|
- name: loop through list with strings
|
|
set_fact:
|
|
list_for_strings: "{% for x in list_one %}{{ x }}{% endfor %}"
|
|
|
|
- assert:
|
|
that:
|
|
- 'list_for_strings == "onetwo"'
|
|
- 'list_for_strings|type_debug in ["str", "unicode"]'
|
|
|
|
- name: loop through list with int
|
|
set_fact:
|
|
list_for_int: "{% for x in list_one_int %}{{ x }}{% endfor %}"
|
|
|
|
- assert:
|
|
that:
|
|
- 'list_for_int == 1'
|
|
- 'list_for_int|type_debug == "int"'
|
|
|
|
- name: loop through list with ints
|
|
set_fact:
|
|
list_for_ints: "{% for x in list_ints %}{{ x }}{% endfor %}"
|
|
|
|
- assert:
|
|
that:
|
|
- 'list_for_ints == 42'
|
|
- 'list_for_ints|type_debug == "int"'
|
|
|
|
- name: loop through list to create a new list
|
|
set_fact:
|
|
list_from_list: "[{% for x in list_ints %}{{ x }},{% endfor %}]"
|
|
|
|
- assert:
|
|
that:
|
|
- 'list_from_list == [4, 2]'
|
|
- 'list_from_list|type_debug == "list"'
|