# Error handling in ios\_config module

**URL:** <https://forum.ansible.com/t/error-handling-in-ios-config-module/20988>\
**Category:** Ansible Project\
**Created:** [March 25, 2016, 2:33pm UTC](https://forum.ansible.com/t/error-handling-in-ios-config-module/20988 "2016-03-25T14:33:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Uros\_Bajzelj](https://avatars.discourse-cdn.com/v4/letter/u/9e8a1a/32.png) [@Uros\_Bajzelj](https://forum.ansible.com/u/Uros_Bajzelj)\
**Post date:** [March 25, 2016, 2:33pm UTC](https://forum.ansible.com/t/error-handling-in-ios-config-module/20988/1 "2016-03-25T14:33:45Z")

</div>

Hello

I am using ios\_config module to configure crypto map on the router.

When you configure the empty crypto map statement the router display the following note:

HQ(config)#crypto map CMAP 10 ipsec-isakmp

% NOTE: This new crypto map will remain disabled until a peer

and a valid access list have been configured.

The problem here is that this error fails the task and ansible does not execute all commands in list. Is there anyway to tell the ansible to ignore this message?

This is my task:

- name: Configure crypto map

ios\_config:

host: “{{ ansible\_ssh\_host }}”

username: “{{ username }}”

password: “{{ password }}”

lines:

- match address GRE-IPSEC

parents: [‘crypto map CMAP {{ item.0 + 1 }} ipsec-isakmp’]

before: [‘no crypto map CMAP {{ item.0 + 1 }} ipsec-isakmp’]

match: strict

with\_indexed\_items: ‘{{ groups.remote }}’

when: “inventory\_hostname in groups.hq”

I also tried to add “ignore\_errors: yes”. But still it does not execute all commands in the lines.

I was reading about failed\_when attribute but I was not able to implement this in the correct way.

(failed\_when: "‘FAILED’ in command\_result.msg)

Any ideas?

BR,

Uros

---

<div class="post-metadata">

**Author:** ![Roger\_Gomez](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@Roger\_Gomez](https://forum.ansible.com/u/Roger_Gomez)\
**Post date:** [March 26, 2016, 2:49pm UTC](https://forum.ansible.com/t/error-handling-in-ios-config-module/20988/2 "2016-03-26T14:49:30Z")

</div>

Maybe you can try blocks [Ansible Blocks](http://docs.ansible.com/ansible/playbooks_blocks.html), they work pretty similar to Python Try/Except/Finally.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Uros\_Bajzelj](https://avatars.discourse-cdn.com/v4/letter/u/9e8a1a/32.png) [@Uros\_Bajzelj](https://forum.ansible.com/u/Uros_Bajzelj)\
**Post date:** [March 28, 2016, 7:55pm UTC](https://forum.ansible.com/t/error-handling-in-ios-config-module/20988/3 "2016-03-28T19:55:19Z")

</div>

Hello

Thanks for the answer. I tried your suggested solution but it does not help.

The problem is that if task fails in the block section, then the rescue section is initiated. But the task fails here as well.

Trying to find other solution… 🙂

BR,

Uros

Dne sobota, 26. marec 2016 15.49.30 UTC+1 je oseba Roger Gomez napisala:

---

<div class="post-metadata">

**Author:** ![psprygada](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@psprygada](https://forum.ansible.com/u/psprygada)\
**Post date:** [March 28, 2016, 11:25pm UTC](https://forum.ansible.com/t/error-handling-in-ios-config-module/20988/4 "2016-03-28T23:25:34Z")

</div>

Its a bug in ios\_config not properly handling the return prompt. Should have a fix committed soon to address this

---

<div class="post-metadata">

**Author:** ![Uros\_Bajzelj](https://avatars.discourse-cdn.com/v4/letter/u/9e8a1a/32.png) [@Uros\_Bajzelj](https://forum.ansible.com/u/Uros_Bajzelj)\
**Post date:** [March 29, 2016, 6:12am UTC](https://forum.ansible.com/t/error-handling-in-ios-config-module/20988/5 "2016-03-29T06:12:01Z")

</div>

Ok great. Just to note, it is the same problem with ios\_command and ios\_template.

BTW: Are you planning to add additional modules to networking section to handle for example access-list only, crypto settings, etc…? I mean like ios\_access\_list to handle ACLs from high level perspective.

BR,

Uros

Dne torek, 29. marec 2016 01.25.44 UTC+2 je oseba Peter Sprygada napisala:

---

<div class="post-metadata">

**Author:** ![psprygada](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@psprygada](https://forum.ansible.com/u/psprygada)\
**Post date:** [March 30, 2016, 2:17am UTC](https://forum.ansible.com/t/error-handling-in-ios-config-module/20988/6 "2016-03-30T02:17:29Z")

</div>

​Should now be fixed in ansible/ansible devel.

no plan as of right now for higher order modules that scrap the cli. you should be able to accomplish most of these tasks with roles today using the current modules as the foundation​

---

<div class="post-metadata">

**Author:** ![Ian\_Zhang](https://avatars.discourse-cdn.com/v4/letter/i/74df32/32.png) [@Ian\_Zhang](https://forum.ansible.com/u/Ian_Zhang)\
**Post date:** [June 2, 2017, 5:13am UTC](https://forum.ansible.com/t/error-handling-in-ios-config-module/20988/7 "2017-06-02T05:13:15Z")

</div>

Is there any update for this issue? i got similar thing need deal but not knowing how to…  
Thanks in advance for any instructions.

Thanks  
-Ian

---

<div class="post-metadata">

**Author:** ![peter216](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/peter216/32/8240_2.png) [@peter216](https://forum.ansible.com/u/peter216)\
**Post date:** [October 18, 2023, 4:32pm UTC](https://forum.ansible.com/t/error-handling-in-ios-config-module/20988/8 "2023-10-18T16:32:30Z")

</div>

This seems to still be broken all these years later. I’m hitting the exact same issue with “crypto map”. Is there a workaround?

ansible --version  
ansible [core 2.15.4]  
config file = /home/plrub160/git/isp\_link\_change/ansible.cfg  
configured module search path = [‘/home/plrub160/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]  
ansible python module location = /home/plrub160/VENV/ISP-LINK-CHANGE/lib/python3.11/site-packages/ansible  
ansible collection location = /home/plrub160/git/isp\_link\_change/collections  
executable location = /home/plrub160/VENV/ISP-LINK-CHANGE/bin/ansible  
python version = 3.11.4 (main, Jul 5 2023, 14:15:25) [GCC 11.2.0] (/home/plrub160/VENV/ISP-LINK-CHANGE/bin/python)  
jinja version = 3.1.2  
libyaml = True
