Re: [ansible-project] json_query & regular expression

2020-04-12 Thread Kiran Kumar
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 |

Re: [ansible-project] json_query & regular expression

2020-04-12 Thread Abhijeet Kasurde
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 - > >

Re: [ansible-project] json_query & regular expression

2020-04-12 Thread Abhijeet Kasurde
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:

Re: [ansible-project] json_query & regular expression

2020-04-12 Thread Vladimir Botka
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", >

Re: [ansible-project] json_query & regular expression

2020-04-12 Thread Kiran Kumar
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",

Re: [ansible-project] json_query & regular expression

2020-04-12 Thread Vladimir Botka
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 >

Re: [ansible-project] json_query & regular expression

2020-04-12 Thread Kiran Kumar
Thanks for the Reply Valdo I get error TASK [debug] * fatal: [localhost]: FAILED! => {"msg": "'str object'

Re: [ansible-project] json_query & regular expression

2020-04-11 Thread Vladimir Botka
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

[ansible-project] json_query & regular expression

2020-04-11 Thread Kiran Kumar
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 --- > -