2018-01-22 16:46:19 +01:00
|
|
|
# Test code for the vmware_guest module.
|
|
|
|
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
- name: Perform all operation in check mode
|
|
|
|
vmware_guest:
|
|
|
|
validate_certs: False
|
2019-04-24 19:58:09 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
name: "{{ infra.vm_list[0] }}"
|
|
|
|
datacenter: "{{ dc1 }}"
|
2018-01-22 16:46:19 +01:00
|
|
|
state: "{{ item }}"
|
|
|
|
with_items:
|
|
|
|
- absent
|
|
|
|
- present
|
|
|
|
- poweredoff
|
|
|
|
- poweredon
|
|
|
|
- restarted
|
|
|
|
- suspended
|
|
|
|
- shutdownguest
|
|
|
|
- rebootguest
|
|
|
|
register: check_mode_state
|
|
|
|
check_mode: yes
|
|
|
|
|
2019-04-24 19:58:09 +02:00
|
|
|
- debug:
|
|
|
|
var: check_mode_state
|
2018-01-22 16:46:19 +01:00
|
|
|
|
|
|
|
- name: assert that changes were made
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "check_mode_state.results|map(attribute='changed')|unique|list == [true]"
|
2019-04-24 19:58:09 +02:00
|
|
|
- "check_mode_state.results|map(attribute='vm_name')|unique|list == [ infra.vm_list[0] ]"
|
2018-01-22 16:46:19 +01:00
|
|
|
|
|
|
|
- name: Perform all operation on non-existent VM in check mode
|
|
|
|
vmware_guest:
|
|
|
|
validate_certs: False
|
2019-04-24 19:58:09 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
2018-01-22 16:46:19 +01:00
|
|
|
name: non_existent_vm
|
2019-04-24 19:58:09 +02:00
|
|
|
datacenter: "{{ dc1 }}"
|
2018-01-22 16:46:19 +01:00
|
|
|
state: "{{ item }}"
|
|
|
|
with_items:
|
|
|
|
- present
|
|
|
|
- poweredoff
|
|
|
|
- poweredon
|
|
|
|
- restarted
|
|
|
|
- suspended
|
|
|
|
register: check_mode_state
|
|
|
|
check_mode: yes
|
|
|
|
|
2019-04-24 19:58:09 +02:00
|
|
|
- debug:
|
|
|
|
var: check_mode_state
|
2018-01-22 16:46:19 +01:00
|
|
|
|
|
|
|
- name: assert that changes were made
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "check_mode_state.results|map(attribute='changed')|unique|list == [true]"
|
|
|
|
- "check_mode_state.results|map(attribute='desired_operation')|unique|list == ['deploy_vm']"
|