ansible/test/integration/targets/vmware_datacenter/tasks/main.yml

51 lines
1.2 KiB
YAML
Raw Normal View History

# Test code for the vmware_datacenter module.
# 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)
- import_role:
name: prepare_vmware_tests
- &add_dc
name: Add datacenter
vmware_datacenter:
validate_certs: False
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter_name: datacenter_0001
state: present
register: dc_result
- debug:
var: dc_result
- name: Ensure datacenter is present
assert:
that:
- dc_result.changed
- <<: *add_dc
name: add datacenter again to check idempotent behavior
- name: Ensure datacenter status is not changed
assert:
that:
- 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