-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_vm.yml
37 lines (33 loc) · 977 Bytes
/
create_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
---
- name: Create VM from Vcenter Template
hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Clone template to new virtual machine
community.vmware.vmware_guest:
validate_certs: false
name: "{{ vm_name }}"
template: template_ubuntu22
datacenter: cihdc
resource_pool: cihtest
folder: "/"
state: poweredon
wait_for_ip_address: true
- name: Set VM IP and Hostname
hosts: 192.168.0.200
tasks:
- name: Update IP
ansible.builtin.lineinfile:
path: /etc/netplan/00-installer-config.yaml
regex: "- 192.168.0.230/24"
line: "- 192.168.0.230"
- name: Update Hostname
ansible.builtin.hostname:
name: "{{ hostname }}.host.vmadmin.local"
- name: Reboot
ansible.builtin.command: "init 6"
ignore_errors: true
- name: Pause for 30 seconds to wait for Reboot
ansible.builtin.pause:
seconds: "30"