2016-10-28 18:50:29 +00:00
|
|
|
---
|
2018-01-05 22:01:45 +00:00
|
|
|
- debug: msg="START connection={{ ansible_connection }}/backup.yaml"
|
|
|
|
- debug: msg="Using provider={{ connection.transport }}"
|
|
|
|
when: ansible_connection == "local"
|
2016-10-28 18:50:29 +00:00
|
|
|
|
2017-09-01 09:44:24 +00:00
|
|
|
# Select interface for test
|
|
|
|
- set_fact: intname="{{ nxos_int1 }}"
|
|
|
|
|
2016-10-28 18:50:29 +00:00
|
|
|
- name: setup
|
|
|
|
nxos_config:
|
|
|
|
commands:
|
|
|
|
- no description
|
|
|
|
- no shutdown
|
|
|
|
parents:
|
2017-09-01 09:44:24 +00:00
|
|
|
- "interface {{ intname }}"
|
2016-10-28 18:50:29 +00:00
|
|
|
match: none
|
2017-08-21 15:15:25 +00:00
|
|
|
provider: "{{ connection }}"
|
2016-10-28 18:50:29 +00:00
|
|
|
|
|
|
|
- name: collect any backup files
|
2018-01-08 15:56:47 +00:00
|
|
|
find: &backups
|
2016-10-28 18:50:29 +00:00
|
|
|
paths: "{{ role_path }}/backup"
|
2017-01-09 17:21:04 +00:00
|
|
|
pattern: "{{ inventory_hostname_short }}_config*"
|
2018-01-08 15:56:47 +00:00
|
|
|
connection: local
|
2016-10-28 18:50:29 +00:00
|
|
|
register: backup_files
|
|
|
|
|
|
|
|
- name: delete backup files
|
|
|
|
file:
|
|
|
|
path: "{{ item.path }}"
|
|
|
|
state: absent
|
|
|
|
with_items: "{{backup_files.files|default([])}}"
|
|
|
|
|
|
|
|
- name: configure device with config
|
|
|
|
nxos_config:
|
2017-09-01 09:44:24 +00:00
|
|
|
commands:
|
|
|
|
- description this is a test
|
|
|
|
- shutdown
|
|
|
|
parents:
|
|
|
|
- "interface {{ intname }}"
|
2016-10-28 18:50:29 +00:00
|
|
|
backup: yes
|
2017-08-21 15:15:25 +00:00
|
|
|
provider: "{{ connection }}"
|
2016-10-28 18:50:29 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
2017-02-25 21:36:00 +00:00
|
|
|
- "result.updates is defined"
|
2016-10-28 18:50:29 +00:00
|
|
|
|
|
|
|
- name: collect any backup files
|
2018-01-08 15:56:47 +00:00
|
|
|
find: *backups
|
|
|
|
connection: local
|
2016-10-28 18:50:29 +00:00
|
|
|
register: backup_files
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- "backup_files.files is defined"
|
|
|
|
|
2018-01-05 22:01:45 +00:00
|
|
|
- debug: msg="END connection={{ ansible_connection }}/backup.yaml"
|