summaryrefslogtreecommitdiff
path: root/test/integration/targets/vmware_guest/tasks/create_d1_c1_f0.yml
blob: b4ee85002d5f9633b1c3b91e89649032520c1bc2 (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Test code for the vmware_guest module.
# Copyright: (c) 2017, James Tanner <tanner.jc@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

- name: create new VMs
  vmware_guest:
    validate_certs: False
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    name: test_vm1
    #template: "{{ item|basename }}"
    guest_id: centos64Guest
    datacenter: "{{ dc1 }}"
    hardware:
        num_cpus: 1
        num_cpu_cores_per_socket: 1
        memory_mb: 128
        hotadd_memory: true
        hotadd_cpu: false
        # vcsim does not support these settings, so commenting
        # till the time.
        # memory_reservation: 128
        # memory_reservation_lock: False
        # nested_virt: True
        # hotremove_cpu: True
        # mem_limit: 8096
        # mem_reservation: 4096
        # cpu_limit: 8096
        # cpu_reservation: 4096
        max_connections: 10
    disk:
        - size: 1gb
          type: thin
          datastore: "{{ rw_datastore }}"
    state: poweredoff
    folder: '{{ f0 }}'
  register: clone_d1_c1_f0

- debug: var=clone_d1_c1_f0

- name: assert that changes were made
  assert:
    that:
        - clone_d1_c1_f0 is changed

- name: create the VM again
  vmware_guest:
    validate_certs: False
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    name: test_vm1
    #template: "{{ item|basename }}"
    guest_id: centos64Guest
    datacenter: "{{ dc1 }}"
    hardware:
        num_cpus: 1
        num_cpu_cores_per_socket: 1
        memory_mb: 128
    disk:
        - size: 1gb
          type: thin
          datastore: "{{ rw_datastore }}"
    state: poweredoff
    folder: '{{ f0 }}'
  register: clone_d1_c1_f0_recreate

- debug: var=clone_d1_c1_f0_recreate

- name: assert that no changes were made after re-creating
  assert:
    that:
        - not (clone_d1_c1_f0_recreate is changed)

- name: modify the new VMs
  vmware_guest:
    validate_certs: False
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    name: test_vm1
    #template: "{{ item|basename }}"
    guest_id: centos64Guest
    datacenter: "{{ dc1 }}"
    hardware:
        num_cpus: 2
        memory_mb: 128
    state: present
    folder: '{{ f0 }}'
  register: clone_d1_c1_f0_modify

- debug: var=clone_d1_c1_f0_modify

- name: assert that changes were made with modification
  assert:
    that:
        - clone_d1_c1_f0_modify is changed

- name: re-modify the new VMs
  vmware_guest:
    validate_certs: False
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    name: test_vm1
    #template: "{{ item|basename }}"
    guest_id: centos64Guest
    datacenter: "{{ dc1 }}"
    hardware:
        num_cpus: 2
        memory_mb: 128
    state: present
    folder: '{{ f0 }}'
  register: clone_d1_c1_f0_remodify

- debug: var=clone_d1_c1_f0_remodify

- name: assert that no changes were made when re-modified
  assert:
    that:
        - not (clone_d1_c1_f0_remodify is changed)

- name: delete the new VMs
  vmware_guest:
    validate_certs: False
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    name: test_vm1
    #template: "{{ item|basename }}"
    #guest_id: centos64Guest
    datacenter: "{{ dc1 }}"
    state: absent
    folder: '{{ f0 }}'
  register: clone_d1_c1_f0_delete

- debug: var=clone_d1_c1_f0_delete

- name: assert that changes were made with deletion
  assert:
    that:
        - clone_d1_c1_f0_delete is changed

- name: re-delete the new VMs
  vmware_guest:
    validate_certs: False
    hostname: "{{ vcenter_hostname }}"
    username: "{{ vcenter_username }}"
    password: "{{ vcenter_password }}"
    name: test_vm1
    #template: "{{ item|basename }}"
    #guest_id: centos64Guest
    datacenter: "{{ dc1 }}"
    state: absent
    folder: '{{ f0 }}'
  register: clone_d1_c1_f0_redelete

- debug: var=clone_d1_c1_f0_redelete

- name: assert that no changes were made with redeletion
  assert:
    that:
        - not (clone_d1_c1_f0_redelete is changed)