ansible/test/integration/targets/aci_config_rollback/tasks/main.yml
Dag Wieers bee765fa6b
ACI: Change RETURN output as discussed (#35617)
* ACI: Change result output as discussed

* Update all modules to use new aci.exit_json()

* Update output_level spec and docs

* Fix integration tests

* Small PEP8 fix

* Asorted fixes to tests and aci_rest

* More test fixes and support for ANSIBLE_DEBUG

* Fix another PEP8 issues

* Move response handling inside ACI module

* Reform of ACI error handling and error output

* Diff multiline json output

* Fix a few more tests

* Revert aci_bd tests

* Small correction

* UI change: existing->current, original->previous

* UI change: config->sent

* Update all modules with RETURN values

* Fix a few more tests

* Improve docstring and add 'raw' return value

* Fix thinko

* Fix sanity/pep8 issues

* Rewrite unit tests to comply with new design
2018-02-03 00:41:56 +01:00

94 lines
3.2 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
host: "{{ aci_hostname }}"
username: "{{ aci_username }}"
password: "{{ aci_password }}"
validate_certs: '{{ aci_validate_certs | default(false) }}'
use_ssl: '{{ aci_use_ssl | default(true) }}'
use_proxy: '{{ aci_use_proxy | default(true) }}'
output_level: debug
state: absent
tenant: anstest
- 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.previous.0.configSnapshotCont.children[-1].configSnapshot.attributes.name }}"
snapshot: "{{ snapshots.previous.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.previous.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 all of the following are missing: import_policy"'
- rollback_rollback.changed == true
- '"ce2_" in rollback_rollback.sent.configImportP.attributes.fileName'
- '".tar.gz" in rollback_rollback.sent.configImportP.attributes.fileName'
- '"fabric/configimp-anstest.json" in rollback_rollback.url'
- tenant_removed.changed == false
- tenant_removed.previous == []