On Sat, 11 Apr 2020 23:35:16 -0700 (PDT)
Kiran Kumar <[email protected]> wrote:

> I get error 
> TASK [debug] 
***********************************************************************************************************************>
fatal: [localhost]: FAILED! => {"msg": "'str object' has no attribute 
> 'guest_name'"}

Take a look at the structure of "vm_fact" and fix it. If you still have issues
post:

    - debug:
        var: vm_fact

> On Saturday, April 11, 2020 at 10:02:06 PM UTC-7, Vladimir Botka wrote:
> > > >   - debug: 
> > > >       msg:  "{{ item.ip_address }}" 
> > > >     with_items: 
> > > >     - "{{ vm_facts.virtual_machines | json_query(query) }}" 
> > > >     vars: 
> > > >       query: "[?guest_name == 'vm1' ]"     
> >
> > Filter "selectattr" should do the job. For example 
> >
> >     - debug: 
> >         msg: "{{ item.ip_address }}" 
> >       loop: "{{ vm_facts| 
> >                 selectattr('guest_name', 'match', '^vm1$')| 
> >                 list }}" 
> >     - debug: 
> >         msg: "{{ item.ip_address }}" 
> >       loop: "{{ vm_facts| 
> >                 selectattr('guest_name', 'match', '^vm(.*)$')| 
> >                 list }}" 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200412090107.72140fe8%40gmail.com.

Attachment: pgpA8ymxxqQSC.pgp
Description: OpenPGP digital signature

Reply via email to