Thanks Abhijeet & Valdo for your time to check. This works !
On Sunday, April 12, 2020 at 9:05:20 AM UTC-7, Abhijeet Kasurde wrote:
>
> Even this works for me - notice ``vm_facts.virtual_machines``
>
> - debug:
> msg: "{{ item.ip_address }}"
> loop: "{{ vm_facts.virtual_machines |
Even this works for me - notice ``vm_facts.virtual_machines``
- debug:
msg: "{{ item.ip_address }}"
loop: "{{ vm_facts.virtual_machines | selectattr('guest_name', 'match',
'^vm(.*)$')| list }}"
On Sun, Apr 12, 2020 at 9:31 PM Abhijeet Kasurde
wrote:
> I would do this in a simpler way -
>
>
I would do this in a simpler way -
- name: Gather all VMs information
vmware_vm_info:
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
validate_certs: no
register: vm_facts
delegate_to: localhost
- debug:
msg: "{{ item.ip_address }}"
loop:
On Sun, 12 Apr 2020 00:26:39 -0700 (PDT)
Kiran Kumar wrote:
> {
> "attributes": {},
> "cluster": "xx",
> "esxi_hostname": "xx",
> "guest_fullname": "Microsoftxx",
> "guest_name": "xx",
>
Thanks for your reply Valdo. This is a JSON output
{
"attributes": {},
"cluster": "xx",
"esxi_hostname": "xx",
"guest_fullname": "Microsoftxx",
"guest_name": "xx",
"ip_address": "xx",
On Sat, 11 Apr 2020 23:35:16 -0700 (PDT)
Kiran Kumar wrote:
> I get error
> TASK [debug]
***>
fatal: [localhost]: FAILED! => {"msg": "'str object' has no attribute
>
Thanks for the Reply Valdo
I get error
TASK [debug]
*
fatal: [localhost]: FAILED! => {"msg": "'str object'
On Sat, 11 Apr 2020 21:26:28 -0700 (PDT)
Kiran Kumar wrote:
> In jason query how can i add regular expression ? eg if have vm1, vm2,vm3
> below query can be adjusted ? eg query: "[?guest_name == 'vm*' ]" ,
> seems does not work in below case
>
> > tasks:
> > - name: Gather all VMs
In jason query how can i add regular expression ? eg if have vm1, vm2,vm3
below query can be adjusted ? eg query: "[?guest_name == 'vm*' ]" ,
seems does not work in below case
https://jmespath.org/specification.html#filterexpressions i tried few
things but no luck
Thanks
---
> -