Advertisement
Guest User

Untitled

a guest
Apr 11th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. - hosts: all
  2. connection: local
  3. become: no
  4.  
  5. vars:
  6. vsphere_hostname: "{{ lookup('env', 'VSPHERE_HOSTNAME') }}"
  7. vsphere_username: "{{ lookup('env', 'VSPHERE_USERNAME') }}"
  8. vsphere_password: "{{ lookup('env', 'VSPHERE_PASSWORD') }}"
  9. vsphere_datacenter: changeme
  10. vsphere_datastore: changeme
  11.  
  12. tasks:
  13.  
  14. - name: build configuration ISO
  15. make:
  16. target: build/{{ inventory_hostname }}.iso
  17. chdir: "{{ playbook_dir }}"
  18.  
  19. - name: upload ISO
  20. vsphere_copy:
  21. hostname: "{{ vsphere_hostname }}"
  22. username: "{{ vsphere_username }}"
  23. password: "{{ vsphere_password }}"
  24. datacenter: "{{ vsphere_datacenter }}"
  25. datastore: "{{ vsphere_datastore }}"
  26. src: build/{{ inventory_hostname }}.iso
  27. path: ISOs/{{ inventory_hostname }}.iso
  28.  
  29. - name: create vm
  30. vsphere_guest:
  31. vcenter_hostname: "{{ vsphere_hostname }}"
  32. username: "{{ vsphere_username }}"
  33. password: "{{ vsphere_password }}"
  34. guest: "{{ inventory_hostname }}"
  35. state: powered_on
  36. vm_disk:
  37. disk1:
  38. size_gb: 16
  39. type: thin
  40. datastore: "{{ vsphere_datastore }}"
  41. vm_nic:
  42. nic1:
  43. network: VM Network
  44. type: vmxnet3
  45. network_type: dvs
  46. vm_hardware:
  47. memory_mb: 2048
  48. num_cpus: 2
  49. osid: centos64Guest
  50. scsi: paravirtual
  51. vm_cdrom:
  52. boot:
  53. type: "iso"
  54. iso_path: "{{ vsphere_datastore }}/boot.iso"
  55. kickstart:
  56. type: "iso"
  57. iso_path: "{{ vsphere_datastore }}/ISOs/{{ inventory_hostname }}.iso"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement