requires GOVC https://github.com/vmware/govmomi/releases

El miércoles, 23 de mayo de 2018, 15:52:40 (UTC+2), Josu Vilda escribió:
>
> After several weeks searching for information and getting it, I give you 
> the playbook.
> Feel free to answer to improve it or show me the faults
>
> After several weeks searching for information and getting it, I give you 
> the playbook.
> Feel free to answer to improve it or show me the faults
>
> ---
> - hosts: "localhost"
>   user: root
>   become: root
>   gather_facts: True
>   tasks:
>     - name: DEFINE VARIABLES
>       set_fact:
>         MEMORIA_MB: "{{ (MEMORIA | int) * 1024 }}"
>       tags:
>         - auto
>
>     - name: CHECK FOR REQUIRED VARIABLES
>       fail: msg="Check the parameters passed"
>       when: VCENTER is not defined or 
>                  NOMBRE is not defined or 
>                  DOMAIN_VCENTER is not definded or 
>                  MEMORIA_MB is not definded or 
>                  PLANTILLA is not definded or 
>                  CLUSTER is not definded or 
>                 CPU is not definded or
>                 HDD is not definded or
>                 REDDATOS is not definded or 
>                 IPDATOS is not definded or 
>                 MASKDATOS is not definded or 
>                 GWDATOS is not definded or 
>                 REDGESTION is not definded or
>                 IPGESTION is not definded or 
>                 MASKGESTION is not definded or 
>                 GWGESTION is not definded or 
>                 DATACENTER is not definded                   
>
>     - name: CREATE A VMWARE FROM TEMPLATE
>       vmware_guest:
>         annotation: "This vmware has been deployed by Ansible"
>         hostname: '{{ VCENTER }}'
>         username: '{{ DOMAIN_VCENTER }}\root'
>         password: 'pass'
>         validate_certs: no
>         datacenter: '{{ DATACENTER }}'
>         cluster: '{{ CLUSTER }}'
>         name: '{{ NOMBRE }}'
>         template: '{{ PLANTILLA }}'
>         state: poweredon
>         folder: '/{{ DATACENTER }}/vm'
>         disk:
>         - autoselect_datastore: "True"
>           size_gb: '{{ HDD }}'
>           type: thin
>         hardware:
>           memory_mb: '{{ MEMORIA_MB }}'
>           num_cpus: '{{ CPU }}'
>           hotadd_cpu: True
>           hotremove_cpu: True
>           hotadd_memory: True
>           scsi: paravirtual
>         networks:
>         - name: '{{ REDDATOS }}'
>           ip: '{{ IPDATOS }}'
>           netmask: '{{ MASKDATOS }}'
>           gateway: '{{ GWDATOS }}'
>         - name: '{{ REDGESTION }}'
>           ip: '{{ IPGESTION }}'
>           netmask: '{{ MASKGESTION }}'
>           gateway: '{{ GWGESTION }}'
>         customization:
>           #ALL
>           domain: '{{ DOMINIO }}.LOCALDOMAIN'
>           hostname: '{{ NOMBRE }}'
>           dns_servers:
>           - 8.8.8.8
>           - 9.9.9.9
>           #WIN
>           orgname: 'EMPRESA'
>           joindomain: '{{ DOMINIO }}.LOCALDOMAIN'
>           domainadmin: 'root'
>           domainadminpassword: "SUPERPASS"
>           password: TEMPORAL
>           autologon: True
>           runonce:
>           - 'C:\Windows\System32\cmd.exe /c "(echo rescan & echo select 
> volume 2 & echo extend ) | diskpart"'
>           - 'c:\windows\system32\wbem\wmic.exe useraccount where 
> name="administrator" rename SUPERUSER'
>           - 'c:\windows\system32\shutdown.exe -r -t 1 -c "deploy"'
>
>       wait_for_ip_address: yes
>       when: not ansible_check_mode
>       async: 1000
>       poll: 0
>       register: deploy
>
>     - name: WAIT FOR THE VM {{ NOMBRE }} CREATION TO FINISH
>       async_status: jid={{ deploy.ansible_job_id }}
>       until: deploy_result.finished
>       retries: 60
>       delay: 30
>       delegate_to: localhost
>       register: deploy_result
>
>     - name: WAIT CUSTOMIZATION
>       shell: export GOVC_USERNAME='localdomain\root' ; export 
> GOVC_PASSWORD='SUPERPASS'; export GOVC_INSECURE='1'; export GOVC_URL=
> https://VPHERE:443; /usr/local/bin/govc events -type 
> CustomizationSucceeded -l=true /CONPRO/vm/{{ NOMBRE }}
>       register: result
>       until: result.stdout.find("CustomizationSucceeded") != -1
>       retries: 50
>       delay: 10
>       delegate_to: localhost
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/537c51bb-75f1-4a74-8368-70da10f5b204%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to