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
.