Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- - hosts: 127.0.0.1
- connection: local
- gather_facts: no
- vars_prompt:
- - name: "vsphere_user"
- private: no
- prompt: "vSphere/ESXi user"
- - name: "vsphere_password"
- private: yes
- prompt: "vSphere/ESXi password"
- - name: "new_vm_name"
- prompt: "New VM Name"
- private: no
- - name: "vm_password"
- prompt: "New Admin Password"
- private: no
- default: "password"
- tasks:
- - name: Deploy the VM
- vmware_guest:
- hostname: DMCISDCPPT37v.DMCI-ISF.COM
- username: "{{ vsphere_user }}"
- password: "{{ vsphere_password }}"
- validate_certs: no
- esxi_hostname: dmcisdnihv901.dmci-isf.com
- datacenter: SDCP-DevOps
- folder: /Demo
- name: "{{ new_vm_name }}"
- state: poweredon
- template: win10-template
- - name: Wait for OOBE Completion and DHCP
- pause:
- seconds: 30
- - name: Attempt to gather accurate VM Guest facts
- vmware_guest_facts:
- datacenter: SDCP-DevOps
- folder: /Demo
- hostname: DMCISDCPPT37v.DMCI-ISF.COM
- name: '{{ new_vm_name }}'
- password: '{{ vsphere_password }}'
- username: '{{ vsphere_user }}'
- validate_certs: no
- delegate_to: localhost
- register: facts
- - name: Add new VM to inventory
- add_host:
- name: '{{facts.instance.ipv4}}'
- ansible_connection: winrm
- ansible_user: xAdministrator
- ansible_password: "{{ vm_password }}"
- ansible_winrm_transport: basic
- ansible_winrm_server_cert_validation: ignore
- groups: newvm
- changed_when: false
- - hosts: [newvm]
- gather_facts: no
- tasks:
- - name: Wait for a connection
- wait_for_connection:
- delay: 180
- sleep: 15
- timeout: 600
- - name: Reboot Machine
- win_reboot:
- - name: Wait for a connection
- wait_for_connection:
- delay: 60
- sleep: 15
- timeout: 600
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement