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
 
.  



-- 
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/80a3e724-f17f-4c87-a1c6-6128ad4a09f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to