在 ESXi 主机上通过 Ansible 部署虚拟机 [英] Deploy a VM via Ansible on ESXi Host
问题描述
我正在尝试通过 Ansible 在 ESXi 主机上部署虚拟机.他们彼此认识(我复制了 SSH ID 文件,所以我们不需要输入密码).所以,我在ansible中使用了以下角色:
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
这是 vmware_deploy.yml 文件:
This is the vmware_deploy.yml file:
---
- hosts: vmware
remote_user: root
roles:
- vmware
ESXi 主机是 172.20.22.5 !
The ESXi host is the 172.20.22.5 !
但是当我查看 ESXi 主机时,什么也没发生……我不知道为什么?他说没关系,但这里没有任何改变或发生?你们知道这里出了什么问题吗?
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:我需要在这个例子中让域、密码、用户和内容看起来不同,这就是为什么列出myuser"、my..."、...
PS: I needed to make the domain, password, user and stuff looking different in this example thats why there is listed "myuser", "my...",...
推荐答案
确保您的 ./roles/vmware/tasks/main.yml
到位.
这篇关于在 ESXi 主机上通过 Ansible 部署虚拟机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!