---
#
#VM Creation
#Written by Joli Martinez
#Date: 12/10/29
#
#This script requires the following to be set
#
#

- hosts: localhost
  #become: yes
  ignore_unreachable: true

  pre_tasks:
  
  vars:
    vcenter_hostname: 10.21.30.250
    vcenter_username: jmartinez@joli.local
    vcenter_password: 0bit7&8!Zbs
    dataCenter: "Datacenter"
    vm_hostname: 
    template: Voice_CentOS7_Template
    
    #B side esx01-06dal1.compute.core.lcl
    #esxi_hostname: esx03dal1.compute.core.lcl
    #cluster: "TX 2323 Bryan Dallas Cluster"
    #vm_dataStore: Filer02dal_sas0

    #A side voicehost04 - 13b.compute.core.lcl
    esxi_hostname: voicehost07b.compute.core.lcl
    cluster: "NJ 165 Halesy Newark Voice Cluster"
    vm_dataStore: Filer03Nwk_SAS0

  roles:

  tasks:

  - name: "Create a virtual machine on the A side"
    vmware_guest:
      datacenter: "{{ dataCenter }}"
      hostname: "{{ vcenter_hostname }}"
      username: "{{ vcenter_username }}"
      password: "{{ vcenter_password }}"
      folder: "/{{ dataCenter }}/vm"
      name: "{{ vm_hostname }}"
      esxi_hostname: "{{ esxi_hostname }}"
      state: poweredon
      template: "{{ template }}"
      validate_certs: no
      networks:
      - name: 2105 F360 Conf_Lab
        #type: dhcp
        ip: 4.3.5.6
        netmask: 255.255.255.0
        gateway: 4.3.5.1
        device_type: vmxnet3
      wait_for_ip_address: no
    delegate_to: localhost
    register: deploy_vm
