Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - 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"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement