I am new in ansible...
After create a guest with vsphere_guest i want to be able :
1. how I can create 5 VM and not just 1
2. how can I give all of them IPs and Hostnames
Thanks Ben
my playbook:
---
- name: Depoly from Template
vsphere_guest:
username: myuser
password: mypassword
guest: newvm001
from_template: yes
template_src: Template6.5-updated
cluster: my_cluster
validate_certs: no
esxi:
datacenter: CONNECT-Lab
hostname: my_esxi_name
- name: Power off the VM server
vsphere_guest:
username: myuser
password: mypassword
guest: newvm001
cluster: my_cluster
validate_certs: no
state: powered_off
esxi:
datacenter: CONNECT-Lab
hostname: my_esxi_name
- name: configure the VLAN , CPU and Memory
vsphere_guest:
username: myuser
password: mypassword
guest: newvm001
validate_certs: no
state: reconfigured
force: yes
vm_extra_config:
vcpu.hotadd: yes
mem.hotadd: yes
notes: This is a test VM
vm_disk:
disk1:
size_gb: 60
type: thin
datastore: my_datastorename
vm_nic:
nic1:
type: VMXNET3
network: my_vlan
network_type: standard
vm_hardware:
memory_mb: 4096
num_cpus: 2
esxi:
datacenter: CONNECT-Lab
hostname: my_esxi_name
- name: PowerOn the VM Server
vsphere_guest:
username: myuser
password: mypassword
guest: newvm001
cluster: my_cluster
validate_certs: no
state: powered_on
esxi:
datacenter: CONNECT-Lab
hostname: my_esxi_name
- name: Getting some Facts
vsphere_guest:
username: myuser
password: mypassword
guest: newvm001
vmware_guest_facts: true
validate_certs: no
register: vmguest_facts
tags: vmfacts
- name: debug facts
debug: msg="vmguest facts are {{ vmguest_facts }}"
tags: vmfacts
- add_host: name={{ hw_eth0.ipaddresses[0] }} groups=virtual