Skip to content

Instantly share code, notes, and snippets.

@flyemsafe
Created January 24, 2019 16:11
Show Gist options
  • Save flyemsafe/dbfad51459de7c90871a1e1a01ada305 to your computer and use it in GitHub Desktop.
Save flyemsafe/dbfad51459de7c90871a1e1a01ada305 to your computer and use it in GitHub Desktop.
Example playbook to bootstrap windows
- name: Provision VMware Instances
vmware_guest:
validate_certs: no
hostname: "{{ esxi_hostname }}"
username: "{{ esxi_username }}"
password: "{{ esxi_password }}"
esxi_hostname: "{{ esxi_target_hostname | default(esxi_hostname) }}"
datacenter: "{{ esxi_datacenter | default('ha-datacenter') }}"
name: "{{ item }}"
folder: "/{{ esxi_datacenter | default('ha-datacenter') }}/{{ esxi_folder | default('vm') }}"
disk:
- "{{ hostvars[item]['disks'] | first }}"
template: "{{ vm_windows_template }}"
networks:
- device_type: e1000e
name: "{{ esxi_net | default('VM Dedicated Net') }}"
start_connected: true
type: dhcp
hardware:
memory_mb: "{{ hostvars[item]['memory'] | default('2048') }}"
num_cpus: "{{ hostvars[item]['cpu'] | default('1') }}"
scsi: paravirtual
hotadd_memory: True
state: "{{ vmstate | default('poweredon') }}"
force: yes
wait_for_ip_address: True
customization:
password: "{{ esxi_password }}"
runonce:
- powershell.exe -ExecutionPolicy Unrestricted -File C:\Windows\Temp\ConfigureRemotingForAnsible.ps1 -ForceNewSSLCert -EnableCredSSP
register: vms
loop: "{{ groups['jenkins'] }}"
tags:
- provision
- cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment