---
- debug: msg="START common/diff_against_file.yaml on connection={{ ansible_connection }}"

- name: Setup a configuration
  exos_config:
    lines:
      - "create vlan 100"
- debug: msg="{{ role_path }}"
- set_fact: master="{{ lookup('file', '{{ role_path }}/templates/master.cfg') }}"

- name: check the running-config against master config
  exos_config:
    diff_against: intended
    intended_config: "{{ master }}"
  diff: yes
  register: result
- assert: 
    that: 
      - "result.diff.before is defined"
      - "result.diff.before is search('configure vlan VLAN_0100 tag 100')"
      - "result.diff.after is defined"

- name: Restore original configuration
  exos_config:
    lines:
      - "delete vlan 100"

- name: Save the configuration to startup
  exos_config:
    save_when: modified
 
- debug: msg="END common/diff_against_file.yaml on connection={{ ansible_connection }}"
