Created
April 11, 2017 06:20
-
-
Save jackprice/f32a7e845aaa6c62b02896c38e3a5e2d to your computer and use it in GitHub Desktop.
Ansible+vSphere+Kickstart Playbook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- hosts: all | |
connection: local | |
become: no | |
vars: | |
vsphere_hostname: "{{ lookup('env', 'VSPHERE_HOSTNAME') }}" | |
vsphere_username: "{{ lookup('env', 'VSPHERE_USERNAME') }}" | |
vsphere_password: "{{ lookup('env', 'VSPHERE_PASSWORD') }}" | |
vsphere_datacenter: changeme | |
vsphere_datastore: changeme | |
tasks: | |
- name: build configuration ISO | |
make: | |
target: build/{{ inventory_hostname }}.iso | |
chdir: "{{ playbook_dir }}" | |
- name: upload ISO | |
vsphere_copy: | |
hostname: "{{ vsphere_hostname }}" | |
username: "{{ vsphere_username }}" | |
password: "{{ vsphere_password }}" | |
datacenter: "{{ vsphere_datacenter }}" | |
datastore: "{{ vsphere_datastore }}" | |
src: build/{{ inventory_hostname }}.iso | |
path: ISOs/{{ inventory_hostname }}.iso | |
- name: create vm | |
vsphere_guest: | |
vcenter_hostname: "{{ vsphere_hostname }}" | |
username: "{{ vsphere_username }}" | |
password: "{{ vsphere_password }}" | |
guest: "{{ inventory_hostname }}" | |
state: powered_on | |
vm_disk: | |
disk1: | |
size_gb: 16 | |
type: thin | |
datastore: "{{ vsphere_datastore }}" | |
vm_nic: | |
nic1: | |
network: VM Network | |
type: vmxnet3 | |
network_type: dvs | |
vm_hardware: | |
memory_mb: 2048 | |
num_cpus: 2 | |
osid: centos64Guest | |
scsi: paravirtual | |
vm_cdrom: | |
boot: | |
type: "iso" | |
iso_path: "{{ vsphere_datastore }}/boot.iso" | |
kickstart: | |
type: "iso" | |
iso_path: "{{ vsphere_datastore }}/ISOs/{{ inventory_hostname }}.iso" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, this doesn't work with vanilla stuff.
Waste of time.