2017-06-27 19:19:17 +02:00
|
|
|
# Test code for the vmware_datacenter module.
|
2017-11-06 17:28:15 +01:00
|
|
|
# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
2019-04-30 12:22:50 +02:00
|
|
|
- import_role:
|
|
|
|
name: prepare_vmware_tests
|
2017-08-08 15:15:51 +02:00
|
|
|
|
2019-04-30 12:22:50 +02:00
|
|
|
- &add_dc
|
|
|
|
name: Add datacenter
|
2017-06-27 19:19:17 +02:00
|
|
|
vmware_datacenter:
|
|
|
|
validate_certs: False
|
2019-04-30 12:22:50 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
2017-06-27 19:19:17 +02:00
|
|
|
datacenter_name: datacenter_0001
|
|
|
|
state: present
|
|
|
|
register: dc_result
|
|
|
|
|
2019-04-30 12:22:50 +02:00
|
|
|
- debug:
|
|
|
|
var: dc_result
|
2017-06-27 19:19:17 +02:00
|
|
|
|
2019-04-30 12:22:50 +02:00
|
|
|
- name: Ensure datacenter is present
|
2017-06-27 19:19:17 +02:00
|
|
|
assert:
|
|
|
|
that:
|
2019-04-30 12:22:50 +02:00
|
|
|
- dc_result.changed
|
2017-06-27 19:19:17 +02:00
|
|
|
|
2019-04-30 12:22:50 +02:00
|
|
|
- <<: *add_dc
|
|
|
|
name: add datacenter again to check idempotent behavior
|
2017-06-27 19:19:17 +02:00
|
|
|
|
2019-04-30 12:22:50 +02:00
|
|
|
- name: Ensure datacenter status is not changed
|
2017-06-27 19:19:17 +02:00
|
|
|
assert:
|
|
|
|
that:
|
2019-04-30 12:22:50 +02:00
|
|
|
- not dc_result.changed
|
|
|
|
|
|
|
|
- when: vcsim is not defined
|
|
|
|
block:
|
|
|
|
- name: Delete datacenter
|
|
|
|
vmware_datacenter:
|
|
|
|
validate_certs: False
|
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
datacenter_name: datacenter_0001
|
|
|
|
state: absent
|
|
|
|
register: dc_result_delete
|
|
|
|
|
|
|
|
- name: Ensure datacenter is absent
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- dc_result_delete.changed
|