# how do I use ios\_config to change configuration to default?

**URL:** <https://forum.ansible.com/t/how-do-i-use-ios-config-to-change-configuration-to-default/24311>\
**Category:** Ansible Project\
**Created:** [April 25, 2017, 6:26pm UTC](https://forum.ansible.com/t/how-do-i-use-ios-config-to-change-configuration-to-default/24311 "2017-04-25T18:26:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Z](https://avatars.discourse-cdn.com/v4/letter/j/e5b9ba/32.png) [@John\_Z](https://forum.ansible.com/u/John_Z)\
**Post date:** [April 25, 2017, 6:26pm UTC](https://forum.ansible.com/t/how-do-i-use-ios-config-to-change-configuration-to-default/24311/1 "2017-04-25T18:26:32Z")

</div>

How do I use ios\_config to delete configuration but only if it is present? I want ios\_config to update many devices to conform to a standard template. It will have to delete configuration as well as add it. I don’t want ios\_config to update a device or increment the change counter if a device is already configured correctly.

Its pretty easy to handle adding or modifying ACLs. For example the following task will modify the acl only if it is different or not present:

- name:configure acl  
ios\_config:  
parents: ip access-list extended jhz-test  
lines:
- permit ip host 1.1.1.1 any log
- permit ip host 2.2.2.2 any log
- permit ip host 3.3.3.3 any log
- permit ip host 4.4.4.4 any log
- permit ip host 5.5.5.5 any log  
before: no ip access-list extended jhz-test  
match: exact  
replace: block  
provider: “{{ creds }}”  
authorize: True

The obvious way to delete configuration is with a “no” command and match = None, but that reconfigures the device and increments the change counter even if the device is already configured correctly. I have tried a couple of other things, but nothing works.

- name: clear acl if present  
ios\_config:  
lines:

- no ip access-list extended jhz-test  
match: non  
provider: “{{ creds }}”  
authorize: True

.

---

<div class="post-metadata">

**Author:** ![Rama\_Krishna](https://avatars.discourse-cdn.com/v4/letter/r/ecd19e/32.png) [@Rama\_Krishna](https://forum.ansible.com/u/Rama_Krishna)\
**Post date:** [May 6, 2017, 12:32am UTC](https://forum.ansible.com/t/how-do-i-use-ios-config-to-change-configuration-to-default/24311/2 "2017-05-06T00:32:47Z")

</div>

Use Jinja2 template with ios\_config, and set the module parameter match: line, which will do the job as you seek.

cheers
