[root@localhost ~]# cat template.yml
---
- name: Create a VM
hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Create a virtual machine on given ESXi hostname
vmware_guest:
hostname: 192.168.45.151
username: root
password: vmware
validate_certs: no
datacenter: dc
folder: /dc/vm/
name: temp
from_template: yes
guest_id: debian6_64Guest
state: present
# This is hostname of particular ESXi server on which user wants VM to be deployed
esxi_hostname: 192.168.45.154
disk:
- size_gb: 10
type: thin
datastore: datastore1
hardware:
memory_mb: 512
num_cpus: 1
scsi: paravirtual
.yml
PLAY [Create a VM] ********************************************************************
TASK [Create a virtual machine on given ESXi hostname] ********************************
changed: [localhost]
PLAY RECAP ****************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
https://docs.google.com/document/d/e/2PACX-1vQoyAk2LYim749eQuu8f1EFKXxyzkq7YkU1bf4D3bkU09ifrqJbwyL-7j3ejQcvD56L42BB4K-gkJDE/pub
temp.yml create vm from above template created
---
- name: Create a VM from a template
hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Clone the template
vmware_guest:
hostname: 192.168.45.151
username: root
password: vmware
validate_certs: False
name: template
template: temp
datacenter: dc
folder: /dc/vm
state: present
wait_for_ip_address: yes
https://docs.google.com/document/d/e/2PACX-1vSOkjdjpDeZs6d32x80Mrh44reM0CyDp0HflG0dIp8ltw8c7l8ZbAAeMO5qsJvfgkBYOa6LWid6kAMu/pub
poweroff vm created by template 'temp' vm name template
https://docs.google.com/document/d/e/2PACX-1vSU6bZqOR3572ECUyieC1gK-RKUBghszB8k0yWPYW07SiJO0xsgY_ogbpGzNrnV34P45INXNdEXkDvi/pub
---
- name: Create a VM
hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Create a virtual machine on given ESXi hostname
vmware_guest:
hostname: 192.168.45.151
username: root
password: vmware
validate_certs: no
datacenter: dc
folder: /dc/vm/
name: temp
from_template: yes
guest_id: debian6_64Guest
state: present
# This is hostname of particular ESXi server on which user wants VM to be deployed
esxi_hostname: 192.168.45.154
disk:
- size_gb: 10
type: thin
datastore: datastore1
hardware:
memory_mb: 512
num_cpus: 1
scsi: paravirtual
root@localhost ~]# ansible-playbook template
.yml
PLAY [Create a VM] ********************************************************************
TASK [Create a virtual machine on given ESXi hostname] ********************************
changed: [localhost]
PLAY RECAP ****************************************************************************
localhost : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
https://docs.google.com/document/d/e/2PACX-1vQoyAk2LYim749eQuu8f1EFKXxyzkq7YkU1bf4D3bkU09ifrqJbwyL-7j3ejQcvD56L42BB4K-gkJDE/pub
temp.yml create vm from above template created
---
- name: Create a VM from a template
hosts: localhost
connection: local
gather_facts: no
tasks:
- name: Clone the template
vmware_guest:
hostname: 192.168.45.151
username: root
password: vmware
validate_certs: False
name: template
template: temp
datacenter: dc
folder: /dc/vm
state: present
wait_for_ip_address: yes
https://docs.google.com/document/d/e/2PACX-1vSOkjdjpDeZs6d32x80Mrh44reM0CyDp0HflG0dIp8ltw8c7l8ZbAAeMO5qsJvfgkBYOa6LWid6kAMu/pub
poweroff vm created by template 'temp' vm name template
https://docs.google.com/document/d/e/2PACX-1vSU6bZqOR3572ECUyieC1gK-RKUBghszB8k0yWPYW07SiJO0xsgY_ogbpGzNrnV34P45INXNdEXkDvi/pub
Comments
Post a Comment