使用ansible模块vmware_guest创建多个VM

时间:2017-08-09 03:45:10

标签: ansible vmware

尝试使用ansible模块vmware_guest创建多个VM。 我收到错误

[IPv4Address('103.21.244.1'),
 IPv4Address('103.21.244.2'),
 IPv4Address('103.21.244.3'),
 IPv4Address('103.21.244.4'),
 IPv4Address('103.21.244.5'),
 ...]

我使用的myvars.yml内容如下:

"msg": "with_dict expects a dict"
 "failed": true

我的任务文件vmspin.yml是:

---
myvms:
   violet:
     - vmhost: violet-vm
       vmip: 192.168.1.163
   yellow:
      - vmhost: yellow-vm
        vmip: 192.168.1.164

任何解决方案

2 个答案:

答案 0 :(得分:1)

说:

with_dict:
  - "{{myvms}}"

将包含myvms dict的单个元素的列表传递给查找。

将其替换为:

with_dict: "{{ myvms }}"

答案 1 :(得分:0)

我认为你必须删除" - "在你的varibles文件中:

myvms:
   violet:
     - vmhost: violet-vm
       vmip: 192.168.1.163
   yellow:
      - vmhost: yellow-vm
        vmip: 192.168.1.164

但:

myvms:
   violet:
     vmhost: violet-vm
     vmip: 192.168.1.163
   yellow:
     vmhost: yellow-vm
     vmip: 192.168.1.164