2017-10-26 17:27:55 +02:00
|
|
|
---
|
2018-01-05 18:39:04 +01:00
|
|
|
- debug: msg="START connection={{ ansible_connection }} nxos_snapshot sanity test"
|
|
|
|
- debug: msg="Using provider={{ connection.transport }}"
|
|
|
|
when: ansible_connection == "local"
|
2017-10-26 17:27:55 +02:00
|
|
|
|
|
|
|
- set_fact: snapshot_run="true"
|
2018-06-05 07:26:32 +02:00
|
|
|
|
|
|
|
- set_fact: snapshot_run="false"
|
|
|
|
when: titanium and (ansible_connection is match('nxapi'))
|
|
|
|
|
2017-10-26 17:27:55 +02:00
|
|
|
- set_fact: snapshot_run="false"
|
2018-06-05 07:26:32 +02:00
|
|
|
when: platform is match('N35')
|
|
|
|
|
|
|
|
- set_fact: add_sec="true"
|
|
|
|
- set_fact: add_sec="false"
|
|
|
|
when: imagetag is search("D1")
|
2017-10-26 17:27:55 +02:00
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: create snapshot
|
2018-06-05 07:26:32 +02:00
|
|
|
nxos_snapshot: &crss1
|
2017-10-26 17:27:55 +02:00
|
|
|
action: create
|
|
|
|
snapshot_name: test_snapshot1
|
|
|
|
description: Ansible
|
2018-06-05 07:26:32 +02:00
|
|
|
save_snapshot_locally: True
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: &true
|
|
|
|
that:
|
|
|
|
- "result.changed == true"
|
|
|
|
|
|
|
|
- name: "Conf Idempotence"
|
|
|
|
nxos_snapshot: *crss1
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: &false
|
|
|
|
that:
|
|
|
|
- "result.changed == false"
|
|
|
|
|
|
|
|
- block:
|
|
|
|
- name: Add section
|
|
|
|
nxos_snapshot: &add
|
|
|
|
action: add
|
|
|
|
section: myshow
|
|
|
|
show_command: show ip interface brief
|
|
|
|
row_id: ROW_intf
|
|
|
|
element_key1: intf-name
|
|
|
|
element_key2: intf-name
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Conf Idempotence"
|
|
|
|
nxos_snapshot: *add
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
|
|
|
when: add_sec
|
2017-10-26 17:27:55 +02:00
|
|
|
|
|
|
|
- name: create another snapshot
|
2018-06-05 07:26:32 +02:00
|
|
|
nxos_snapshot: &crss2
|
2017-10-26 17:27:55 +02:00
|
|
|
action: create
|
|
|
|
snapshot_name: test_snapshot2
|
|
|
|
description: row
|
|
|
|
section: myshow
|
|
|
|
show_command: show ip interface brief
|
|
|
|
row_id: ROW_intf
|
|
|
|
element_key1: intf-name
|
2018-06-05 07:26:32 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Conf Idempotence"
|
|
|
|
nxos_snapshot: *crss2
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
2017-10-26 17:27:55 +02:00
|
|
|
|
|
|
|
- name: compare snapshots
|
|
|
|
nxos_snapshot:
|
|
|
|
action: compare
|
|
|
|
snapshot1: test_snapshot1
|
|
|
|
snapshot2: test_snapshot2
|
|
|
|
comparison_results_file: compare_snapshots.txt
|
|
|
|
compare_option: summary
|
|
|
|
path: '.'
|
|
|
|
|
2018-06-05 07:26:32 +02:00
|
|
|
- name: delete snapshot
|
|
|
|
nxos_snapshot: &del
|
|
|
|
snapshot_name: test_snapshot2
|
|
|
|
action: delete
|
2018-03-09 13:17:14 +01:00
|
|
|
register: result
|
|
|
|
|
2018-06-05 07:26:32 +02:00
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Conf Idempotence"
|
|
|
|
nxos_snapshot: *del
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
|
|
|
|
|
|
|
- name: delete all snapshots
|
|
|
|
nxos_snapshot: &delall
|
|
|
|
action: delete_all
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *true
|
|
|
|
|
|
|
|
- name: "Conf Idempotence"
|
|
|
|
nxos_snapshot: *delall
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *false
|
2018-03-09 13:17:14 +01:00
|
|
|
|
2017-10-26 17:27:55 +02:00
|
|
|
when: snapshot_run
|
|
|
|
|
|
|
|
always:
|
2018-06-05 07:26:32 +02:00
|
|
|
- name: delete all sections
|
|
|
|
nxos_config:
|
|
|
|
commands:
|
|
|
|
- snapshot section delete myshow
|
|
|
|
match: none
|
|
|
|
ignore_errors: yes
|
|
|
|
|
|
|
|
- name: delete all snapshots
|
2017-10-26 17:27:55 +02:00
|
|
|
nxos_snapshot:
|
|
|
|
action: delete_all
|
|
|
|
ignore_errors: yes
|
|
|
|
|
2018-01-05 18:39:04 +01:00
|
|
|
- debug: msg="END connection={{ ansible_connection }} nxos_snapshot sanity test"
|