I have the following playbook and would like to know if it is expected behavior that ‘changed_when:false’ would cause the the differences between the two files not to be shown in the output.
My goal with this playbook is to use it to audit some configurations to demonstrate Ansible’s capabilities to a colleague before we use it to actually update configurations.
Running this with $ansible-playbook check.yml --check --diff -vvvv
#This playbook will compare the running configuration against a reference file and note the differences
- hosts: myhost
gather_facts: false
remote_user: user
tasks:- name: compare running configuration against master (a reference file)
ios_config:
diff_against: intended
intended_config: “{{ lookup(‘file’, ‘master.cfg’) }}”
match: line
diff_ignore_lines:- ntp clock .*
- secret 5 *
- hostname *
- date *
diff: true
register: diff_results
changed_when: false
— before
+++ after
@@ -1,4 +1,3 @@
-Tue Jun 12 09:17:06.698 MDT
clock timezone MST MST7MDT
service timestamps log datetime localtime msec show-timezone
service timestamps debug datetime localtime msec show-timezone
@@ -11,6 +10,7 @@
address-family ipv4 unicast
ntp
server vrf Management 1.2.3.4
- server vrf Management 5.6.7.8
Its probably worth mentioning that the only difference between the running config and the intended configuration is the addition of a line: “server vrf Management 5.6.7.8”.
thank you.