Re: [ansible-project] Re: eos_command module waitfor - IP address in json structure

2016-03-23 Thread Peter Sprygada
My pleasure, glad you found it helpful.

On Wed, Mar 23, 2016 at 3:41 PM, Martin Baro 
wrote:

> Thanks Peter, much appreciated.
> Also thanks for the great network webinar, was really informative.
>
> Martin
>
> On Wednesday, March 23, 2016 at 7:40:56 AM UTC+1, Peter Sprygada wrote:
>>
>> (ansible)[ansible-eos]$ cat route.yaml
>> ---
>> - hosts: veos01
>>   gather_facts: no
>>
>>   vars:
>> route: 1.1.1.1/32
>>
>>   tasks:
>> - eos_command:
>> commands:
>>   - show ip route | json
>> waitfor:
>>   - "result[0].vrfs.default.routes[{{ route
>> }}].hardwareProgrammed eq true"
>> provider: "{{ cli }}"
>>
>>
>> (ansible)[ansible-eos]$ ansible-playbook route.yaml
>>
>> PLAY [veos01]
>> **
>>
>> TASK [eos_command]
>> *
>> ok: [veos01]
>>
>> PLAY RECAP
>> *
>> veos01 : ok=1changed=0unreachable=0
>>  failed=0
>>
>> On Wed, Mar 23, 2016 at 2:39 AM, Peter Sprygada 
>> wrote:
>>
>>> Ignore the request for filing an issue, I committed a change that should
>>> fix this problem. The fix is available for testing in ansible/ansible devel
>>>
>>> On Tue, Mar 22, 2016 at 4:25 PM, Peter Sprygada 
>>> wrote:
>>>
 Thats a bug... could you file an issue at
 github.com/ansible/ansible-modules-core please?

 On Tue, Mar 22, 2016 at 2:17 PM, Martin Baro 
 wrote:

> Hi Uditha,
>
> Thanks for the reply.
> I've simplified the problem a bit (just removed the variable) and with
> removing the "" around the whole statement I managed to preserve the 
> quotes.
> Unfortunately it didn't solve the problem:
>
> waitfor:
>- result[0].vrfs.default.routes[\'
> 1.2.3.4/30\'].hardwareProgrammed
>  eq true
>
> The error was: ValueError: result[0].vrfs.default.routes['
> 1.2.3.4/30'].hardwareProgrammed
> 
>
> The issue is the same with double quotes around the IP address.
>
>
>
>
> On Tuesday, March 22, 2016 at 2:50:05 PM UTC+1, Uditha Desilva wrote:
>>
>> It may need more protection for those quotes -- perhaps this?
>>
>>- "result[0].vrfs.default.routes[\'{{ route 
>> }}\'].hardwareProgrammed
>> eq true"
>>
>>>
> --
> 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 ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/7f5a3e93-84cc-43c7-b11f-50ccb849971a%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>


>>>
>> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/b0ae52f7-b3a7-4f4d-820a-4389a4921e1b%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEkdrMg-2gOc_oQbMkSiUrW-hUq5JJqYzmmX%2BDjwC0ua_SLz5w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: eos_command module waitfor - IP address in json structure

2016-03-23 Thread Martin Baro
Thanks Peter, much appreciated.
Also thanks for the great network webinar, was really informative.

Martin

On Wednesday, March 23, 2016 at 7:40:56 AM UTC+1, Peter Sprygada wrote:
>
> (ansible)[ansible-eos]$ cat route.yaml
> ---
> - hosts: veos01
>   gather_facts: no
>
>   vars:
> route: 1.1.1.1/32
>
>   tasks:
> - eos_command:
> commands:
>   - show ip route | json
> waitfor:
>   - "result[0].vrfs.default.routes[{{ route }}].hardwareProgrammed 
> eq true"
> provider: "{{ cli }}"
>
>
> (ansible)[ansible-eos]$ ansible-playbook route.yaml
>
> PLAY [veos01] 
> **
>
> TASK [eos_command] 
> *
> ok: [veos01]
>
> PLAY RECAP 
> *
> veos01 : ok=1changed=0unreachable=0failed=0
>
> On Wed, Mar 23, 2016 at 2:39 AM, Peter Sprygada  > wrote:
>
>> Ignore the request for filing an issue, I committed a change that should 
>> fix this problem. The fix is available for testing in ansible/ansible devel
>>
>> On Tue, Mar 22, 2016 at 4:25 PM, Peter Sprygada > > wrote:
>>
>>> Thats a bug... could you file an issue at 
>>> github.com/ansible/ansible-modules-core please?
>>>
>>> On Tue, Mar 22, 2016 at 2:17 PM, Martin Baro >> > wrote:
>>>
 Hi Uditha,

 Thanks for the reply.
 I've simplified the problem a bit (just removed the variable) and with 
 removing the "" around the whole statement I managed to preserve the 
 quotes.
 Unfortunately it didn't solve the problem:

 waitfor:
- result[0].vrfs.default.routes[\'
 1.2.3.4/30\'].hardwareProgrammed 
  eq true

 The error was: ValueError: result[0].vrfs.default.routes['
 1.2.3.4/30'].hardwareProgrammed 
 

 The issue is the same with double quotes around the IP address.




 On Tuesday, March 22, 2016 at 2:50:05 PM UTC+1, Uditha Desilva wrote:
>
> It may need more protection for those quotes -- perhaps this?
>
>- "result[0].vrfs.default.routes[\'{{ route 
> }}\'].hardwareProgrammed 
> eq true"
>
>>
 -- 
 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 ansible-proje...@googlegroups.com .
 To post to this group, send email to ansible...@googlegroups.com 
 .
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/ansible-project/7f5a3e93-84cc-43c7-b11f-50ccb849971a%40googlegroups.com
  
 
 .

 For more options, visit https://groups.google.com/d/optout.

>>>
>>>
>>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b0ae52f7-b3a7-4f4d-820a-4389a4921e1b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: eos_command module waitfor - IP address in json structure

2016-03-22 Thread Peter Sprygada
(ansible)[ansible-eos]$ cat route.yaml
---
- hosts: veos01
  gather_facts: no

  vars:
route: 1.1.1.1/32

  tasks:
- eos_command:
commands:
  - show ip route | json
waitfor:
  - "result[0].vrfs.default.routes[{{ route }}].hardwareProgrammed
eq true"
provider: "{{ cli }}"


(ansible)[ansible-eos]$ ansible-playbook route.yaml

PLAY [veos01]
**

TASK [eos_command]
*
ok: [veos01]

PLAY RECAP
*
veos01 : ok=1changed=0unreachable=0failed=0

On Wed, Mar 23, 2016 at 2:39 AM, Peter Sprygada 
wrote:

> Ignore the request for filing an issue, I committed a change that should
> fix this problem. The fix is available for testing in ansible/ansible devel
>
> On Tue, Mar 22, 2016 at 4:25 PM, Peter Sprygada 
> wrote:
>
>> Thats a bug... could you file an issue at
>> github.com/ansible/ansible-modules-core please?
>>
>> On Tue, Mar 22, 2016 at 2:17 PM, Martin Baro 
>> wrote:
>>
>>> Hi Uditha,
>>>
>>> Thanks for the reply.
>>> I've simplified the problem a bit (just removed the variable) and with
>>> removing the "" around the whole statement I managed to preserve the quotes.
>>> Unfortunately it didn't solve the problem:
>>>
>>> waitfor:
>>>- result[0].vrfs.default.routes[\'
>>> 1.2.3.4/30\'].hardwareProgrammed
>>>  eq true
>>>
>>> The error was: ValueError: result[0].vrfs.default.routes['
>>> 1.2.3.4/30'].hardwareProgrammed
>>> 
>>>
>>> The issue is the same with double quotes around the IP address.
>>>
>>>
>>>
>>>
>>> On Tuesday, March 22, 2016 at 2:50:05 PM UTC+1, Uditha Desilva wrote:

 It may need more protection for those quotes -- perhaps this?

- "result[0].vrfs.default.routes[\'{{ route }}\'].hardwareProgrammed
 eq true"

>
>>> --
>>> 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 ansible-project+unsubscr...@googlegroups.com.
>>> To post to this group, send email to ansible-project@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/ansible-project/7f5a3e93-84cc-43c7-b11f-50ccb849971a%40googlegroups.com
>>> 
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEkdrMjeNF_BG%2BHdMtr-rXX3EscTtEFkUr-wgEjuOE75WrBTRQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: eos_command module waitfor - IP address in json structure

2016-03-22 Thread Peter Sprygada
Ignore the request for filing an issue, I committed a change that should
fix this problem. The fix is available for testing in ansible/ansible devel

On Tue, Mar 22, 2016 at 4:25 PM, Peter Sprygada 
wrote:

> Thats a bug... could you file an issue at
> github.com/ansible/ansible-modules-core please?
>
> On Tue, Mar 22, 2016 at 2:17 PM, Martin Baro 
> wrote:
>
>> Hi Uditha,
>>
>> Thanks for the reply.
>> I've simplified the problem a bit (just removed the variable) and with
>> removing the "" around the whole statement I managed to preserve the quotes.
>> Unfortunately it didn't solve the problem:
>>
>> waitfor:
>>- result[0].vrfs.default.routes[\'1.2.3.4/30\'].hardwareProgrammed
>>  eq true
>>
>> The error was: ValueError: result[0].vrfs.default.routes['
>> 1.2.3.4/30'].hardwareProgrammed
>> 
>>
>> The issue is the same with double quotes around the IP address.
>>
>>
>>
>>
>> On Tuesday, March 22, 2016 at 2:50:05 PM UTC+1, Uditha Desilva wrote:
>>>
>>> It may need more protection for those quotes -- perhaps this?
>>>
>>>- "result[0].vrfs.default.routes[\'{{ route }}\'].hardwareProgrammed
>>> eq true"
>>>

>> --
>> 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 ansible-project+unsubscr...@googlegroups.com.
>> To post to this group, send email to ansible-project@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/ansible-project/7f5a3e93-84cc-43c7-b11f-50ccb849971a%40googlegroups.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEkdrMi%2BY8sJjFmWF%3DosrHAkCCRwOB0s9ex%3D2qwyg9A52-odBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Re: eos_command module waitfor - IP address in json structure

2016-03-22 Thread Peter Sprygada
Thats a bug... could you file an issue at
github.com/ansible/ansible-modules-core please?

On Tue, Mar 22, 2016 at 2:17 PM, Martin Baro 
wrote:

> Hi Uditha,
>
> Thanks for the reply.
> I've simplified the problem a bit (just removed the variable) and with
> removing the "" around the whole statement I managed to preserve the quotes.
> Unfortunately it didn't solve the problem:
>
> waitfor:
>- result[0].vrfs.default.routes[\'1.2.3.4/30\'].hardwareProgrammed
>  eq true
>
> The error was: ValueError: result[0].vrfs.default.routes['
> 1.2.3.4/30'].hardwareProgrammed 
>
> The issue is the same with double quotes around the IP address.
>
>
>
>
> On Tuesday, March 22, 2016 at 2:50:05 PM UTC+1, Uditha Desilva wrote:
>>
>> It may need more protection for those quotes -- perhaps this?
>>
>>- "result[0].vrfs.default.routes[\'{{ route }}\'].hardwareProgrammed
>> eq true"
>>
>>>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/7f5a3e93-84cc-43c7-b11f-50ccb849971a%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEkdrMg--AsjVUyE4sMifigAh36zfHk9qNL4gspggHULutvOSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: eos_command module waitfor - IP address in json structure

2016-03-22 Thread Martin Baro
Hi Uditha,

Thanks for the reply.
I've simplified the problem a bit (just removed the variable) and with 
removing the "" around the whole statement I managed to preserve the quotes.
Unfortunately it didn't solve the problem:

waitfor:
   - result[0].vrfs.default.routes[\'1.2.3.4/30\'].hardwareProgrammed 
eq true

The error was: ValueError: 
result[0].vrfs.default.routes['1.2.3.4/30'].hardwareProgrammed

The issue is the same with double quotes around the IP address.




On Tuesday, March 22, 2016 at 2:50:05 PM UTC+1, Uditha Desilva wrote:
>
> It may need more protection for those quotes -- perhaps this?
>
>- "result[0].vrfs.default.routes[\'{{ route }}\'].hardwareProgrammed 
> eq true"
>
>>


-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/7f5a3e93-84cc-43c7-b11f-50ccb849971a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: eos_command module waitfor - IP address in json structure

2016-03-22 Thread Uditha Desilva
It may need more protection for those quotes -- perhaps this?

   - "result[0].vrfs.default.routes[\'{{ route }}\'].hardwareProgrammed 
eq true"

>
>>>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/f0171b26-e7bc-4d3a-a890-60b7cb88dc4a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: eos_command module waitfor - IP address in json structure

2016-03-21 Thread Martin Baro
Hi,

It seems it`s not evaluating the routes[] part:
with your waitfor:

ValueError: result[0].vrfs.default.routes[1.2.3.4/30].hardwareProgrammed

I also tried to index it with [0] without success:

ValueError: result[0].vrfs.default.routes[0].hardwareProgrammed




On Monday, March 21, 2016 at 6:07:43 PM UTC+1, Uditha Desilva wrote:
>
> The dotted form is a shorthand for using braces, so maybe this will work:
>
>- "result[0].vrfs.default.routes['{{ route }}'].hardwareProgrammed 
> eq true"
>
> On Monday, 21 March 2016 16:56:35 UTC, Martin Baro wrote:
>>
>> Hi
>>
>> I`m trying to catch a specific route in the waitfor statment if it is 
>> present from a show ip route output.
>> However I think ansible misinterprets the statement because of the dots 
>> in the IP address.
>> (I can successfully test other values like 
>> vrfs.default.defaultRouteState )
>> The playbook:
>> ---
>>
>> - name: test playbook
>>   hosts: veos
>>   gather_facts: no
>>   connection: local
>>   vars:
>>route: "1.2.3.4/30"
>>   tasks:
>>- name: show ip route
>>  eos_command:
>>   commands:
>>- show ip route | json
>>   username: ansible
>>   password: ansible
>>   host: x.x.x.x
>>   transport: cli
>>   waitfor:
>>- "result[0].vrfs.default.routes.{{ route }}.hardwareProgrammed eq 
>> true"
>>
>> The error was: ValueError: 
>> result[0].vrfs.default.routes.1.2.3.4/30.hardwareProgrammed
>>
>> The json structure is:
>> "vrfs": {
>> "default": {
>> "allRoutesProgrammedHardware": true,
>> "allRoutesProgrammedKernel": true,
>> "defaultRouteState": "notSet",
>> "routes": {
>> "1.2.3.4/30": {
>> "directlyConnected": true,
>> "hardwareProgrammed": true,
>> "kernelProgrammed": true,
>> "routeAction": "forward",
>> "routeType": "connected",
>> "vias": [
>> {
>> "interface": "Ethernet2"
>> }
>> ]
>> },
>> "192.168.48.0/24": {
>> "directlyConnected": true,
>> "hardwareProgrammed": true,
>> "kernelProgrammed": true,
>> "routeAction": "forward",
>> "routeType": "connected",
>> "vias": [
>> {
>> "interface": "Ethernet1"
>> }
>> ]
>> }
>>
>> Is there any way I can reference the specific route?
>>
>> Thanks,
>>
>> Martin
>>
>>
>>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/3c4b6fd3-b78d-482e-93ab-0ef7854d2b1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: eos_command module waitfor - IP address in json structure

2016-03-21 Thread Uditha Desilva
The dotted form is a shorthand for using braces, so maybe this will work:

   - "result[0].vrfs.default.routes['{{ route }}'].hardwareProgrammed 
eq true"

On Monday, 21 March 2016 16:56:35 UTC, Martin Baro wrote:
>
> Hi
>
> I`m trying to catch a specific route in the waitfor statment if it is 
> present from a show ip route output.
> However I think ansible misinterprets the statement because of the dots in 
> the IP address.
> (I can successfully test other values like vrfs.default.defaultRouteState 
> )
> The playbook:
> ---
>
> - name: test playbook
>   hosts: veos
>   gather_facts: no
>   connection: local
>   vars:
>route: "1.2.3.4/30"
>   tasks:
>- name: show ip route
>  eos_command:
>   commands:
>- show ip route | json
>   username: ansible
>   password: ansible
>   host: x.x.x.x
>   transport: cli
>   waitfor:
>- "result[0].vrfs.default.routes.{{ route }}.hardwareProgrammed eq 
> true"
>
> The error was: ValueError: 
> result[0].vrfs.default.routes.1.2.3.4/30.hardwareProgrammed
>
> The json structure is:
> "vrfs": {
> "default": {
> "allRoutesProgrammedHardware": true,
> "allRoutesProgrammedKernel": true,
> "defaultRouteState": "notSet",
> "routes": {
> "1.2.3.4/30": {
> "directlyConnected": true,
> "hardwareProgrammed": true,
> "kernelProgrammed": true,
> "routeAction": "forward",
> "routeType": "connected",
> "vias": [
> {
> "interface": "Ethernet2"
> }
> ]
> },
> "192.168.48.0/24": {
> "directlyConnected": true,
> "hardwareProgrammed": true,
> "kernelProgrammed": true,
> "routeAction": "forward",
> "routeType": "connected",
> "vias": [
> {
> "interface": "Ethernet1"
> }
> ]
> }
>
> Is there any way I can reference the specific route?
>
> Thanks,
>
> Martin
>
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6b74da0b-9b57-4b8d-a94c-3f453597de71%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.