On Sun, 12 Apr 2020 00:26:39 -0700 (PDT)
Kiran Kumar <
esxi...@gmail.com> wrote:
> {
> "attributes": {},
> "cluster": "xx",
> "esxi_hostname": "xx",
> "guest_fullname": "Microsoftxx",
> "guest_name": "xx",
> "ip_address": "xx",
> "mac_address": [
> "xx"
> ],
> "power_state": "poweredOn",
> "tags": [],
> "uuid": "xx",
> "vm_network": {
> "xx": {
> "ipv4": [
> "xx"
> ],
> "ipv6": []
> }
>
> > fatal: [localhost]: FAILED! => {"msg": "'str object' has no attribute
> > > 'guest_name'"}
> > > >
> > > > - debug:
> > > > msg: "{{ item.ip_address }}"
> > > > loop: "{{ vm_facts|
> > > > selectattr('guest_name', 'match', '^vm(.*)$')|
> > > > list }}"
There shouldn't be any problem with the dictionary "vm_facts" you posted. The
attribute "guest_name" is in place. I can't explain the error. It's up to you
to fix the JSON paths.