-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvsphere_test.yaml
37 lines (34 loc) · 1.04 KB
/
vsphere_test.yaml
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
---
- hosts: vmcreate
gather_facts: false
connection: local
vars:
vcenter_hostname: hq-l-lvc2.kpsc.lan
esxhost: hq-l-esxi12.kpsc.lan
datastore: tintri01
network: portgroup-x
vmtemplate: cent7
vmcluster: hq-cl2
notes: Created by Ansible
tasks:
- name: Check for required variables
fail: msg="Must pass name to -e"
when: name is not defined
- name: Check for vSphere accesss
fail: msg="Must set vcenter_user and vcenter_pass in a vault"
when: (vcenter_user is not defined) or (vcenter_pass is not defined)
- name: Create VM from template
vsphere_guest:
vcenter-hostname: "{{ vcenter-hostname }}"
username: "{{ vcenter_user }}"
password: "{{ vcenter_pass }}"
guest: "{{ name }}"
from_template: yes
template_src: "{{ vmtemplate }}"
cluster: "{{ vmcluster }}"
resource_pool: "/Resources"
vm_extra_config:
notes: "{{ notes }}"
esxi:
datacenter: hq-l-dc1
hostname: "{{ esxhost }}"