-
Notifications
You must be signed in to change notification settings - Fork 6
/
vmware_create_multiple_vm.yml
50 lines (49 loc) · 1.56 KB
/
vmware_create_multiple_vm.yml
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
- name: Create VM
hosts: localhost
gather_facts: no
vars:
vmcluster: Cluster01
vmdatacenter: lab
vmfolder: /{{ vmdatacenter }}/vm/Ansible
vmname_list:
- { name: 'vm01', datastore: 'datastore1', network: 'DPortGroup1', cpu: '1', mem: '256' }
- { name: 'vm02', datastore: 'datastore1', network: 'DPortGroup2', cpu: '1', mem: '256' }
tasks:
- name: Debug input list (loop)
debug:
var: "{{ item }}"
with_items : "{{ vmname_list }}"
tags: debug
- name: Create a new CentOS VM
vmware_guest:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
validate_certs: no
datacenter: "{{ vmdatacenter }}"
cluster: "{{ vmcluster }}"
folder: "{{ vmfolder }}"
name: "{{ item.name }}"
state: poweredoff
guest_id: centos64Guest
datastore: "{{ item.datastore }}"
disk:
- size_gb: 10
type: thin
hardware:
memory_mb: "{{ item.mem }}"
num_cpus: "{{ item.cpu }}"
scsi: paravirtual
boot_firmware: efi
networks:
- name: "{{ item.network }}"
device_type: vmxnet3
customvalues:
- key: "svga.vgaOnly"
Value: true
register: vmdeploy_list
with_items: "{{ vmname_list }}"
- name: Debug result list
debug:
var: "{{ vmdeploy_list }}"
tags: debug