summaryrefslogtreecommitdiff
path: root/test/integration/targets/incidental_vmware_guest/tasks/vapp_d1_c1_f0.yml
blob: bd83f97db61c788e30cd24643d8fe94116720d94 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Test code for the vmware_guest module.
# Copyright: (c) 2018, goshkis
# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

- &vapp_new_vm
  name: Create test VM with vAPP settings
  vmware_guest:
    validate_certs: False
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    folder: "vm"
    name: test_vm1
    datacenter: "{{ dc1 }}"
    cluster: "{{ ccr1 }}"
    resource_pool: Resources
    guest_id: centos64Guest
    hardware:
      memory_mb: 128
      num_cpus: 1
      scsi: paravirtual
    disk:
    - size_mb: 128
      type: thin
      datastore: "{{ rw_datastore }}"
    vapp_properties:
    - id: prop_id1
      category: category
      label: prop_label1
      type: string
      value: prop_value1
    - id: prop_id2
      category: category
      label: prop_label2
      type: string
      value: prop_value2
  register: vapp_vm

- debug: var=vapp_vm

- name: assert the vApp propeties were created
  assert:
    that:
      - "vapp_vm.failed == false"
      - "vapp_vm.changed == true"

- when: vcsim is not defined
  block:
    - <<: *vapp_new_vm
      name: Try to create same VM with same vAPP settings
      register: vapp_vm_no_change

    - debug: var=vapp_vm_no_change

    - name: Assert that vApp properties were not changed
      assert:
        that:
          - "vapp_vm_no_change.failed == false"
          - "not vapp_vm_no_change.changed"

- &vapp_edit_vm
  name: Edit one vApp property and removing another
  vmware_guest:
    validate_certs: False
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    folder: "vm"
    name: test_vm1
    datacenter: "{{ dc1 }}"
    vapp_properties:
    - id: prop_id1
      operation: remove
    - id: prop_id2
      value: prop_value3
    state: present
  register: vapp_vm

- debug: var=vapp_vm

- name: assert the VM was changed
  assert:
    that:
      - "vapp_vm.failed == false"
      - "vapp_vm.changed == true"

- when: vcsim is not defined
  block:
    - <<: *vapp_edit_vm
      name: Try to edit VM with vApp settings
      register: vapp_vm_no_change_edit

    - debug: var=vapp_vm_no_change_edit

    - name: assert the VM was changed
      assert:
        that:
          - "vapp_vm_no_change_edit.failed == false"
          - "vapp_vm_no_change_edit.changed == false"