69 lines
1.1 KiB
YAML
69 lines
1.1 KiB
YAML
|
- name: Set a fact
|
||
|
set_fact:
|
||
|
a:
|
||
|
b:
|
||
|
c:
|
||
|
- 1
|
||
|
- 2
|
||
|
|
||
|
- name: Update the fact
|
||
|
ansible.utils.update_fact:
|
||
|
updates:
|
||
|
- path: a.b.c.0
|
||
|
value: 10
|
||
|
- path: "a['b']['c'][1]"
|
||
|
value: 20
|
||
|
register: updated
|
||
|
|
||
|
- assert:
|
||
|
that: "{{ updated.a == expected.a }}"
|
||
|
vars:
|
||
|
expected:
|
||
|
a:
|
||
|
b:
|
||
|
c:
|
||
|
- 10
|
||
|
- 20
|
||
|
|
||
|
- name: Update the fact
|
||
|
ansible.utils.update_fact:
|
||
|
updates:
|
||
|
- path: a
|
||
|
value:
|
||
|
x:
|
||
|
y:
|
||
|
z:
|
||
|
- 100
|
||
|
- True
|
||
|
register: updated
|
||
|
|
||
|
- assert:
|
||
|
that: "{{ updated.a == expected.a }}"
|
||
|
vars:
|
||
|
expected:
|
||
|
a:
|
||
|
x:
|
||
|
y:
|
||
|
z:
|
||
|
- 100
|
||
|
- True
|
||
|
|
||
|
- name: Update the fact
|
||
|
ansible.utils.update_fact:
|
||
|
updates:
|
||
|
- path: "a.b.c[{{ index }}]"
|
||
|
value: 20
|
||
|
vars:
|
||
|
index: "{{ a.b.c|ansible.utils.index_of('eq', 2) }}"
|
||
|
register: updated
|
||
|
|
||
|
- assert:
|
||
|
that: "{{ updated.a == expected.a }}"
|
||
|
vars:
|
||
|
expected:
|
||
|
a:
|
||
|
b:
|
||
|
c:
|
||
|
- 1
|
||
|
- 20
|