-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvm.yml
More file actions
113 lines (101 loc) · 3.61 KB
/
vm.yml
File metadata and controls
113 lines (101 loc) · 3.61 KB
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
# Create a new VM on an ESX server
# Returns changed = False when the VM already exists
# Returns changed = True and a adds ansible_facts from the new VM
# State will set the power status of a guest upon creation. Use powered_on to create and boot.
# Options ['state', 'vm_extra_config', 'vm_disk', 'vm_nic', 'vm_hardware', 'esxi'] are required together
# Note: vm_floppy support added in 2.0
---
- name: create some vms
hosts: vmware
vars_prompt:
- name: "vcenter_pass"
prompt: "Enter vcenter password"
private: yes
tasks:
- vsphere_guest:
vcenter_hostname: 192.168.2.51
username: root
password: "{{ vcenter_pass }}"
guest: hadoop01
state: powered_on
vm_extra_config:
vcpu.hotadd: yes
mem.hotadd: yes
notes: This is a test VM
folder: MyFolder
vm_disk:
disk1:
size_gb: 10
type: thin
datastore: datastore1
# VMs can be put into folders. The value given here is either the full path
# to the folder (e.g. production/customerA/lamp) or just the last component
# of the path (e.g. lamp):
folder: hadoop01
vm_nic:
nic1:
type: vmxnet3
network: VM Network
network_type: standard
# nic2:
# type: vmxnet3
# network: dvSwitch Network
# network_type: dvs
vm_hardware:
memory_mb: 512
num_cpus: 2
osid: ubuntu64Guest
scsi: paravirtual
vm_cdrom:
type: "iso"
iso_path: "iso/ubuntu-16.04.1-server-amd64.iso"
# vm_floppy:
# type: "image"
# image_path: "DatastoreName/floppy-image.flp"
esxi:
datacenter: MyDatacenter
hostname: 192.168.2.51
# Task to gather facts from a vSphere cluster only if the system is a VMware guest
# - vsphere_guest:
# vcenter_hostname: vcenter.mydomain.local
# username: myuser
# password: mypass
# guest: newvm001
# vmware_guest_facts: yes
# Typical output of a vsphere_facts run on a guest
# If vmware tools is not installed, ipadresses with return None
# - hw_eth0:
# - addresstype: "assigned"
# label: "Network adapter 1"
# macaddress: "00:22:33:33:44:55"
# macaddress_dash: "00-22-33-33-44-55"
# ipaddresses: ['192.0.2.100', '2001:DB8:56ff:feac:4d8a']
# summary: "VM Network"
# hw_guest_full_name: "newvm001"
# hw_guest_id: "rhel6_64Guest"
# hw_memtotal_mb: 2048
# hw_name: "centos64Guest"
# hw_power_status: "POWERED ON"
# hw_processor_count: 2
# hw_product_uuid: "ef50bac8-2845-40ff-81d9-675315501dac"
# hw_power_status will be one of the following values:
# - POWERED ON
# - POWERED OFF
# - SUSPENDED
# - POWERING ON
# - POWERING OFF
# - SUSPENDING
# - RESETTING
# - BLOCKED ON MSG
# - REVERTING TO SNAPSHOT
# - UNKNOWN
# as seen in the VMPowerState-Class of PySphere: http://git.io/vlwOq
# Remove a vm from vSphere
# The VM must be powered_off or you need to use force to force a shutdown
# - vsphere_guest:
# vcenter_hostname: vcenter.mydomain.local
# username: myuser
# password: mypass
# guest: newvm001
# state: absent
# force: yes