You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/integration/targets/aci_config_rollback/tasks/main.yml

92 lines
3.0 KiB
YAML

# Test code for the ACI modules
# Copyright 2017, Jacob McGill <jmcgill298
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: Test that we have an ACI APIC host, ACI username and ACI password
fail:
msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.'
when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined
- name: ensure tenant does not exist for tests to kick off
aci_tenant: &aci_tenant_absent
hostname: "{{ aci_hostname }}"
username: "{{ aci_username }}"
password: "{{ aci_password }}"
validate_certs: no
tenant: anstest
state: absent
- name: create a snapshot
aci_config_snapshot: &create_snapshot
<<: *aci_tenant_absent
state: present
tenant: "{{ fakevar | default(omit) }}"
export_policy: anstest
- name: create a tenant - use for rollback
aci_tenant: &aci_tenant
<<: *create_snapshot
export_policy: "{{ fakevar | default(omit) }}"
tenant: anstest
register: tenant_present
- name: create a new snapshot
aci_config_snapshot:
<<: *create_snapshot
- name: get snapshots
aci_config_snapshot:
<<: *create_snapshot
state: query
register: snapshots
- name: compare snapshots
aci_config_rollback: &preview_rollback
<<: *create_snapshot
state: preview
compare_export_policy: anstest
compare_snapshot: "{{ snapshots.existing.0.configSnapshotCont.children[-1].configSnapshot.attributes.name }}"
snapshot: "{{ snapshots.existing.0.configSnapshotCont.children[-2].configSnapshot.attributes.name }}"
register: rollback_preview
- name: rollback to snapshot
aci_config_rollback: &aci_rollback
<<: *create_snapshot
state: rollback
snapshot: "{{ snapshots.existing.0.configSnapshotCont.children[-1].configSnapshot.attributes.name }}"
ignore_errors: yes
register: rollback_missing_param
- name: rollback to snapshot
aci_config_rollback:
<<: *aci_rollback
import_policy: anstest
import_type: replace
import_mode: atomic
register: rollback_rollback
- name: pause execution to let rollback take affect
pause:
seconds: 15
- name: ensure tenant doesn't exist after rollback
aci_tenant:
<<: *aci_tenant_absent
register: tenant_removed
- name: rollback assertions
assert:
that:
- rollback_preview.changed == false
- '"<fvTenant name=\"anstest\" rn=\"tn-anstest\" status=\"deleted\">" in rollback_preview.diff'
- '"snapshots.diff.xml" in rollback_preview.url'
- rollback_missing_param.failed == true
- 'rollback_missing_param.msg == "state is rollback but the following are missing: import_policy"'
- rollback_rollback.changed == true
- '"ce2_" in rollback_rollback.config.configImportP.attributes.fileName'
- '".tar.gz" in rollback_rollback.config.configImportP.attributes.fileName'
- '"fabric/configimp-anstest.json" in rollback_rollback.url'
- tenant_removed.changed == false
- tenant_removed.existing == []