Deploy a VM via Ansible on ESXi Host

2019-07-31 03:39发布

问题:

i am trying to deploy a VM via Ansible on an ESXi Host. They both know each other (i copied the SSH ID File, so we do not need to enter a password). so, i used the following role in ansible:

- vsphere_guest:
    vcenter_hostname: emea-esx-s18t.mydomain.net
    username: myuser
    password: mypassword
    guest: newvm001
    state: powered_off
    vm_extra_config:
      vcpu.hotadd: yes
      mem.hotadd:  yes
      notes: This is a test VM
    vm_disk:
      disk1:
        size_gb: 10
        type: thin
        datastore: storage001
    vm_nic:
      nic1:
        type: vmxnet3
        network: VM Network
        network_type: standard
    vm_hardware:
      memory_mb: 4096
      num_cpus: 4
      osid: windows7Server64Guest
      scsi: paravirtual
    esxi:
      datacenter: MyDatacenter
      hostname: esx-s18t.mydomain.net

So while u use this role, i get the following output:

root@ansible1:~/ansible# ansible-playbook -i Inventory vmware_deploy.yml

PLAY ***************************************************************************

TASK [setup] *******************************************************************
ok: [172.20.22.5]

PLAY RECAP *********************************************************************
172.20.22.5                : ok=1    changed=0    unreachable=0    failed=0

This is the vmware_deploy.yml file:

---
- hosts: vmware
  remote_user: root
  roles:
   - vmware

The ESXi host is the 172.20.22.5 !

But when i take a look on the ESXi Host, nothing happend.. i dont know why? he said its okay but nothing changed or happend here? Do you guys maybe know whats wrong here?

PS: I needed to make the domain, password, user and stuff looking different in this example thats why there is listed "myuser", "my...",...

回答1:

Make sure that your ./roles/vmware/tasks/main.yml is in place.