creating multiple vms from template temper with poweredon state improved

[root@localhost ~]# vi createvms
[web-vms]
ans-web[01:05] disk='10' datastore='datastore1'  memory='512' cpucount='1' guest_id='rhel6Guest'


[root@localhost ~]# cat zing1.yml
---
- hosts: all
  gather_facts: false
  connection: local
  vars_prompt:
    - name: "vsphere_password"
      prompt: "vSphere Password"
    - name: "notes"
      prompt: "VM notes"
      private: no
      default: "Deployed with ansible"
  tasks:
  # get date
  - set_fact: creationdate="{{lookup('pipe','date "+%Y/%m/%d %H:%M"')}}"
  # Create a VM from a template
  - name: create the VM
    vmware_guest:
      hostname: 192.168.0.103
      username: root
      password: vmware
      validate_certs: no
      esxi_hostname: 192.168.0.108
      datacenter: dc
      folder: /dc/vm
      name: '{{ inventory_hostname }}'
      state: poweredon
      guest_id: rhel6Guest
      annotation: "{{ notes }} - {{ creationdate }}"
      disk:
      - size_gb: 10
        type: thin
        datastore: datastore1
      hardware:
        memory_mb: 512
        num_cpus: 1
        scsi: paravirtual
        hostname: '{{ inventory_hostname }}'
      template: temper
      wait_for_ip_address: True
[root@localhost ~]# ansible-playbook -i createvms zing1.yml
vSphere Password:
VM notes [Deployed with ansible]:

PLAY [all] **********************************************************************************

TASK [set_fact] *****************************************************************************
ok: [ans-web01]
ok: [ans-web02]
ok: [ans-web04]
ok: [ans-web05]
ok: [ans-web03]

TASK [create the VM] ************************************************************************
changed: [ans-web04]
changed: [ans-web05]
changed: [ans-web03]
changed: [ans-web01]
changed: [ans-web02]

PLAY RECAP **********************************************************************************
ans-web01                  : ok=2    changed=1    unreachable=0    failed=0   
ans-web02                  : ok=2    changed=1    unreachable=0    failed=0   
ans-web03                  : ok=2    changed=1    unreachable=0    failed=0   
ans-web04                  : ok=2    changed=1    unreachable=0    failed=0   
ans-web05                  : ok=2    changed=1    unreachable=0    failed=0   

[root@localhost ~]#


https://docs.google.com/document/d/e/2PACX-1vRahkOv1pFGauouzV9nnGeHSyfjKsF6YCv5kfJJ2QIwonkbRAptUDQ5hdjhqVZGA6T0SA6fuLBOFy1n/pub

Comments