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" |
Yeah, this doesn't work with vanilla stuff.
Waste of time.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi Jack, i like your easy concept.
But the core ansible vsphere_guest has not the vm_cdrom: kickstart function. ->http://docs.ansible.com/ansible/vsphere_guest_module.html
Do you use a custom vsphere_guest module?
How do I get the kickstart function?
I use the ansible 2.3.1.0
Thanks and best regards
Freddy