Guest User

Untitled

a guest
Feb 26th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. ---
  2.  
  3. - name: Create VM
  4. hosts: localhost
  5. gather_facts: no
  6.  
  7. vars:
  8. vcenter_server: xxx.xx.xx.xx
  9. vcenter_user: admin@vsphere.local
  10. vcenter_pass: xxxxxx
  11.  
  12. tasks:
  13. - set_fact:
  14. vm_name: "ansible_test"
  15. datacenter_name: "DC01"
  16. cluster_name: "Test Cluster"
  17. vm_folder: /Non-Production/Test Servers
  18. esxi_hostname: my_host
  19. memory: 1024
  20. cpu: 2
  21.  
  22. - name: Crete new VM
  23. vmware_guest:
  24. hostname: "{{ vcenter_server }}"
  25. username: "{{ vcenter_user }}"
  26. password: "{{ vcenter_pass }}"
  27. validate_certs: no
  28. folder: "{{ vm_folder }}"
  29. name: "{{ vm_name }}"
  30. state: poweredon
  31. guest_id: centos64Guest
  32. esxi_hostname: "{{ esxi_hostname }}"
  33. datacenter: "{{ datacenter_name }}"
  34. disk:
  35. - size_gb: 40
  36. type: thin
  37. datastore: UXEM Datastore 5
  38. autoselect_datastore: yes
  39. hardware:
  40. memory_mb: "{{ memory }}"
  41. num_cpus: "{{ cpu }}"
  42. scsi: lsilogic
  43. wait_for_ip_address: yes
  44. delegate_to: localhost
  45. register: deploy_vm
  46.  
  47. ...
  48.  
  49.  
  50. [root@DCOPANSIAP01 playbooks]# ansible-playbook vmware_create_vm.yml -vvv
  51. ansible-playbook 2.7.7
  52. config file = /etc/ansible/ansible.cfg
  53. configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  54. ansible python module location = /usr/lib/python2.7/site-packages/ansible
  55. executable location = /usr/bin/ansible-playbook
  56. python version = 2.7.5 (default, Sep 12 2018, 05:31:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
  57. Using /etc/ansible/ansible.cfg as config file
  58. /etc/ansible/hosts did not meet host_list requirements, check plugin documentation if this is unexpected
  59. /etc/ansible/hosts did not meet script requirements, check plugin documentation if this is unexpected
  60. Parsed /etc/ansible/hosts inventory source with ini plugin
  61.  
  62. PLAYBOOK: vmware_create_vm.yml *****************************************************************************************************************************************
  63. 1 plays in vmware_create_vm.yml
  64.  
  65. PLAY [Reconfigure VM] **************************************************************************************************************************************************
  66. META: ran handlers
  67.  
  68. TASK [set_fact] ********************************************************************************************************************************************************
  69. task path: /etc/ansible/playbooks/vmware_create_vm.yml:13
  70. ok: [localhost] => {
  71. "ansible_facts": {
  72. "cluster_name": "Test Cluster",
  73. "cpu": 2,
  74. "datacenter_name": "DC01",
  75. "esxi_hostname": "my_host",
  76. "memory": 1024,
  77. "vm_folder": "/Non-Production/Test Servers",
  78. "vm_name": "ansible_test"
  79. },
  80. "changed": false
  81. }
  82.  
  83. TASK [Crete new VM] ****************************************************************************************************************************************************
  84. task path: /etc/ansible/playbooks/vmware_create_vm.yml:22
  85. <localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
  86. <localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
  87. <localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp/ansible-tmp-1551202153.43-45324044914895 `" && echo ansible-tmp-1551202153.43-45324044914895="` echo /root/.ansible/tmp/ansible-tmp-1551202153.43-45324044914895 `" ) && sleep 0'
  88. Using module file /usr/lib/python2.7/site-packages/ansible/modules/cloud/vmware/vmware_guest.py
  89. <localhost> PUT /root/.ansible/tmp/ansible-local-113215A8Leqx/tmp_9MrJa TO /root/.ansible/tmp/ansible-tmp-1551202153.43-45324044914895/AnsiballZ_vmware_guest.py
  90. <localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1551202153.43-45324044914895/ /root/.ansible/tmp/ansible-tmp-1551202153.43-45324044914895/AnsiballZ_vmware_guest.py && sleep 0'
  91. <localhost> EXEC /bin/sh -c '/usr/bin/python2 /root/.ansible/tmp/ansible-tmp-1551202153.43-45324044914895/AnsiballZ_vmware_guest.py && sleep 0'
Add Comment
Please, Sign In to add comment