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

- name: configure vlan
  exos_config:
    lines:
      - create vlan 100
    backup: yes
    backup_options:
      filename: backup.cfg
      dir_path: '{{ role_path }}'
  register: result

- set_fact: content="{{ lookup('file', '{{ role_path }}/backup.cfg') }}"

- name: Assert local file creation
  assert:
    that:
      - "content is search('Module devmgr')"

- name: delete configurable backup file path
  file:
    path: "{{ role_path }}/backup.cfg"
    state: absent

- 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/backup.yaml on connection={{ ansible_connection }}"
