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

cheers

On Wednesday, April 26, 2017 at 6:39:48 PM UTC+5:30, John Z wrote:
>
> 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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/bb5390d1-7c6c-41fd-a41d-47e67db9171d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to