'Ansible - Combine Nested Array from variable
I need some advice/help for a problem that i can't manage to solve at this time :(
This is my first post on this site so dont be that bad with me if i'm on the wrong section.
Here the problem :
- First i call the vmware api to retrieve vmware cluster id (OK for this)
- From the array of clusters id i manage to call the api to retrieve all hosts from these
- Creating my array of hosts created multiple array into my var like this :
Here the task Ansible that create these array in my var
- name: Virt-Who Reconfigure - Set Fact Hosts for Cluster "{{ cluster_redhat_regex }}" and "{{ cluster_poc_regex }}"
set_fact: vmware_cluster_redhat_poc_tmp={{ vmware_cluster_redhat_poc_hosts.results | json_query('[*].json.value[*].name') }}
when: manage_org_covea == True
Example of the output of the task (hiden info for security)
{
"changed": false,
"ansible_facts": {
"my_vars": [
[
"host-xxx.local.domain",
],
[
"host-xxx.local.domain",
],
[
"host-xxx.local.domain",
],
[
"host-xxx.local.domain,
],
[
"host-xxx.local.domain,
],
[
"host-xxx.local.domain",
],
[
"host-xxx.local.domain",
"host-xxx.local.domain"
],
[
"host-xxx.local.domain",
"host-xxx.local.domain"
]
]
},
"_ansible_no_log": false
}
I'm trying to combine all these "nested array" from the var into a single array but i'm stuck !
The expected result is something like this bellow :
{
"changed": false,
"ansible_facts": {
"my_vars": [
[
"host-xxx.local.domain",
"host-xxx.local.domain",
"host-xxx.local.domain",
"host-xxx.local.domain,
"host-xxx.local.domain,
"host-xxx.local.domain",
"host-xxx.local.domain",
"host-xxx.local.domain"
"host-xxx.local.domain",
"host-xxx.local.domain"
]
]
},
"_ansible_no_log": false
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
