Re: [ansible-project] Help with ios_command Module

2020-04-22 Thread Srinivas Naram
You can use ignore_errors=True

On Wed, Apr 22, 2020 at 6:48 PM Omar Hegazy 
wrote:

> Hello, i have 2 switches. I wanted to run a command (show arp) and check a
> specific output if exist or not on both. Then, i wanted to run a command
> (show arp) and display the output.
>
> The problem is that since the output i'm inspecting on first task doesn't
> exist on switch1  the next task (Display Output) is not performed for
> switch 1. i don't know why this dependency. I thought that there
> shouldn't be dependencies between tasks this way. How to overcome?
> --
>
>-
>
>hosts: SWITCHES
>
>tasks:
>-
>
>   name: run show and check to see if output contains value
>   ios_command:
>   commands: "show arp"
>   wait_for: result[0] contains aabb.cc00.3000
>   -
>
>   name: Get Shows
>   ios_command:
>   commands: "show arp"
>   register: Output
>   -
>
>   name: Display Output
>   debug:
>   msg: "{{ Output.stdout_lines[0] }}"
>
> Output:
>
> PLAY [SWITCHES]
> **
>
> TASK [run show version and check to see if output contains IOS]
> **
> ok: [switch2]
> fatal: [switch1]: FAILED! => {"changed": false, "failed_conditions":
> ["result[0] contains aabb.cc00.3000"], "msg": "One or more conditional
> statements have not been satisfied"}
>
> TASK [Get Shows]
> *
> ok: [switch2]
>
> TASK [Display Output]
> 
> ok: [switch2] => {
> "msg": [
> "Protocol Address Age (min) Hardware Addr Type Interface",
> "Internet 192.168.0.1 0 342c.c4ad.9a81 ARPA Ethernet0/0",
> "Internet 192.168.0.157 - aabb.cc00.3000 ARPA Ethernet0/0",
> "Internet 192.168.0.248 0 d4d2.5287.83ef ARPA Ethernet0/0"
> ]
> }
>
> PLAY RECAP
> ***
> switch1 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0
> ignored=0
> switch2 : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0
> ignored=0
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/2a134fb2-ebd2-46a7-b3a8-f141d95b4fef%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAG-N3P5Twu%2Bb2%3DaaAN_cd042KQhVDPdhR5hRSX5cT_DFfhD3QA%40mail.gmail.com.


[ansible-project] Help with ios_command Module

2020-04-22 Thread Omar Hegazy


Hello, i have 2 switches. I wanted to run a command (show arp) and check a 
specific output if exist or not on both. Then, i wanted to run a command 
(show arp) and display the output.

The problem is that since the output i'm inspecting on first task doesn't 
exist on switch1  the next task (Display Output) is not performed for 
switch 1. i don't know why this dependency. I thought that there 
shouldn't be dependencies between tasks this way. How to overcome?
--

   - 
   
   hosts: SWITCHES
   
   tasks:
   - 
  
  name: run show and check to see if output contains value
  ios_command:
  commands: "show arp"
  wait_for: result[0] contains aabb.cc00.3000
  - 
  
  name: Get Shows
  ios_command:
  commands: "show arp"
  register: Output
  - 
  
  name: Display Output
  debug:
  msg: "{{ Output.stdout_lines[0] }}"
  
Output: 

PLAY [SWITCHES] 
**

TASK [run show version and check to see if output contains IOS] 
**
ok: [switch2]
fatal: [switch1]: FAILED! => {"changed": false, "failed_conditions": 
["result[0] contains aabb.cc00.3000"], "msg": "One or more conditional 
statements have not been satisfied"}

TASK [Get Shows] 
*
ok: [switch2]

TASK [Display Output] 

ok: [switch2] => {
"msg": [
"Protocol Address Age (min) Hardware Addr Type Interface",
"Internet 192.168.0.1 0 342c.c4ad.9a81 ARPA Ethernet0/0",
"Internet 192.168.0.157 - aabb.cc00.3000 ARPA Ethernet0/0",
"Internet 192.168.0.248 0 d4d2.5287.83ef ARPA Ethernet0/0"
]
}

PLAY RECAP 
***
switch1 : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 
ignored=0
switch2 : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 
ignored=0

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/2a134fb2-ebd2-46a7-b3a8-f141d95b4fef%40googlegroups.com.