Identifying differences on a file using Ansible

Compare differences in a configuration file using the following play-book:


– hosts: voss
gather_facts: no
become: yes

tasks:
– name: diff against running config
voss_config:
diff_against: intended
intended_config: “{{ lookup(‘file’, ‘vsp.cfg’) }}”

Sample output where I changed the prompt name on the switch and beforehand captured the running config (terminal more disable) to a file ‘vsp.cfg’.

$ ansible-playbook test-diff.yml -l voss –diff

:

— before
+++ after
@@ -1,7 +1,8 @@
+=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2022.02.20 16:35:12 =~=~=~=~=~=~=~=~=~=~=~=
+show run
config terminal
no boot config flags spbm-config-mode
boot config flags sshd
-prompt “switch-01”
password password-history 3
ssh
ip pim enable
@@ -47,4 +48,5 @@
router ospf
router rip
exit
-end
\ No newline at end of file
+end
+VSP-8284XSQ:1#
\ No newline at end of file

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s