Reputation: 35
I am attempting to parse through the return value but ansible is acting like the long JSON doesn't exist. I know there are similar problems like this but everything I have tried dosn't seem to work.
- name:
community.vmware.vmware_host_config_info:
esxi_hostname: "{{ inventory_hostname }}"
hostname: "{{ inventory_hostname }}"
password: "{{ ansible_password }}"
username: "{{ ansible_user }}"
validate_certs: no
register: config_info
delegate_to: localhost
- debug:
var: config_info
I have tried
config_info.host_info[0]
config_info.host_info[localhost.localdomain]
config_info.host_info.localhost.localdomain
No matter what I attempt, the best I can do is get a
VARIABLE IS NOT DEFINED
I am trying to get the value of the fields i.e config_info.host_info[0].BufferCache.FlushInterval
is what I would expect it to be.
{
"changed": false,
"hosts_info": {
"localhost.localdomain": {
"Annotations.WelcomeMessage": "",
"BufferCache.FlushInterval": 30000,
"BufferCache.HardMaxDirty": 95
}
}
Upvotes: 1
Views: 164
Reputation: 68034
You have to use the bracket notation
bc_fi: "{{ config_info.hosts_info['localhost.localdomain']['BufferCache.FlushInterval'] }}"
gives
bc_fi: '30000'
Upvotes: 1