mirror of https://github.com/ansible/ansible.git
correctly merge multiple facts results (#68987)
* correctly merge multiple facts results fixes #68532pull/67995/head
parent
fe941a4045
commit
9281148b62
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- now correclty merge and not just overwrite facts when gathering using multiple modules.
|
@ -1 +1,2 @@
|
||||
shippable/posix/group3
|
||||
needs/root
|
||||
|
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo '{
|
||||
"changed": false,
|
||||
"ansible_facts": {
|
||||
"factsone": "from facts_one module",
|
||||
"common_fact": "also from facts_one module",
|
||||
"common_dict_fact": {
|
||||
"key_one": "from facts_one",
|
||||
"key_two": "from facts_one"
|
||||
},
|
||||
"common_list_fact": [
|
||||
"one",
|
||||
"three",
|
||||
"five"
|
||||
],
|
||||
"common_list_fact2": [
|
||||
"one",
|
||||
"two",
|
||||
"three",
|
||||
"five",
|
||||
"five"
|
||||
]
|
||||
}
|
||||
}'
|
@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo '{
|
||||
"changed": false,
|
||||
"ansible_facts": {
|
||||
"factstwo": "from facts_two module",
|
||||
"common_fact": "also from facts_two module",
|
||||
"common_dict_fact": {
|
||||
"key_two": "from facts_two",
|
||||
"key_four": "from facts_two"
|
||||
},
|
||||
"common_list_fact": [
|
||||
"one",
|
||||
"two",
|
||||
"four"
|
||||
],
|
||||
"common_list_fact2": [
|
||||
"one",
|
||||
"two",
|
||||
"four",
|
||||
"four"
|
||||
]
|
||||
}
|
||||
}'
|
@ -0,0 +1,27 @@
|
||||
{
|
||||
"_ansible_facts_gathered": true,
|
||||
"common_dict_fact": {
|
||||
"key_four": "from facts_two",
|
||||
"key_one": "from facts_one",
|
||||
"key_two": "from facts_two"
|
||||
},
|
||||
"common_fact": "also from facts_two module",
|
||||
"common_list_fact": [
|
||||
"three",
|
||||
"five",
|
||||
"one",
|
||||
"two",
|
||||
"four"
|
||||
],
|
||||
"common_list_fact2": [
|
||||
"three",
|
||||
"five",
|
||||
"five",
|
||||
"one",
|
||||
"two",
|
||||
"four",
|
||||
"four"
|
||||
],
|
||||
"factsone": "from facts_one module",
|
||||
"factstwo": "from facts_two module"
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
{
|
||||
"_ansible_facts_gathered": true,
|
||||
"common_dict_fact": {
|
||||
"key_four": "from facts_two",
|
||||
"key_one": "from facts_one",
|
||||
"key_two": "from facts_one"
|
||||
},
|
||||
"common_fact": "also from facts_one module",
|
||||
"common_list_fact": [
|
||||
"two",
|
||||
"four",
|
||||
"one",
|
||||
"three",
|
||||
"five"
|
||||
],
|
||||
"common_list_fact2": [
|
||||
"four",
|
||||
"four",
|
||||
"one",
|
||||
"two",
|
||||
"three",
|
||||
"five",
|
||||
"five"
|
||||
],
|
||||
"factsone": "from facts_one module",
|
||||
"factstwo": "from facts_two module"
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
- name: rune one and two, verify merge is as expected
|
||||
hosts: localhost
|
||||
vars:
|
||||
ansible_facts_modules:
|
||||
- facts_one
|
||||
- facts_two
|
||||
tasks:
|
||||
|
||||
- name: populate original
|
||||
include_vars:
|
||||
name: original
|
||||
file: one_two.json
|
||||
|
||||
- name: fail if ref file is updated
|
||||
assert:
|
||||
msg: '{{ansible_facts}} vs {{original}}'
|
||||
that:
|
||||
- ansible_facts|to_json(indent=4, sort_keys=True) == original|to_json(indent=4, sort_keys=True)
|
||||
|
||||
- name: clear existing facts for next play
|
||||
meta: clear_facts
|
||||
|
||||
|
||||
- name: rune two and one, verify merge is as expected
|
||||
hosts: localhost
|
||||
vars:
|
||||
ansible_facts_modules:
|
||||
- facts_two
|
||||
- facts_one
|
||||
tasks:
|
||||
|
||||
- name: populate original
|
||||
include_vars:
|
||||
name: original
|
||||
file: two_one.json
|
||||
|
||||
- name: fail if ref file is updated
|
||||
assert:
|
||||
msg: '{{ansible_facts}} vs {{original}}'
|
||||
that:
|
||||
- ansible_facts|to_json(indent=4, sort_keys=True) == original|to_json(indent=4, sort_keys=True)
|
Loading…
Reference in New Issue