【问题标题】:Host should be a string error in ansible主机应该是ansible中的字符串错误
【发布时间】:2016-09-02 04:43:00
【问题描述】:

这是我运行此代码时遇到的错误。

[my-host]
 19.3.112.97  ansible_ssh_pass=mypass ansible_ssh_user=root

剧本是

---
- hosts: localhost
  connection: local
  tasks:
    - vsphere_guest:
        guest: newvm001
        vmware_guest_facts: yes

错误:

任务执行期间发生异常。完整的追溯是: Traceback(最近一次通话最后一次):文件 "/var/folders/zt/s5ykx9_n4y9611h_k_gj_vx00000gn/T/ansible_vYePRK/ansible_module_vsphere_guest.py", 第 1879 行,在 主()文件“/var/folders/zt/s5ykx9_n4y9611h_k_gj_vx00000gn/T/ansible_vYePRK/ansible_module_vsphere_guest.py”, 第 1748 行,主要 viserver.connect(vcenter_hostname, username, password) 文件“/Library/Python/2.7/site-packages/pysphere/vi_server.py”,第 71 行,在 连接 ,FaultTypes.PARAMETER_ERROR) pysphere.resources.vi_exception.VIException: [参数错误]: 'host' 应该是一个带有 ESX/VC url 的字符串。

致命:[9.1.142.86]:失败! => {“改变”:假,“失败”:真, “调用”:{“module_name”:“vsphere_guest”},“module_stderr”: "回溯(最近一次调用最后一次):\n 文件 \"/var/folders/zt/s5ykx9_n4y9611h_k_gj_vx00000gn/T/ansible_vYePRK/ansible_module_vsphere_guest.py\", 第 1879 行,在 \n main()\n 文件中 \"/var/folders/zt/s5ykx9_n4y9611h_k_gj_vx00000gn/T/ansible_vYePRK/ansible_module_vsphere_guest.py\", 第 1748 行,在 main\n viserver.connect(vcenter_hostname, username, 密码)\n 文件 \"/Library/Python/2.7/site-packages/pysphere/vi_server.py\",第 71 行, 连接中\n
,FaultTypes.PARAMETER_ERROR)\npysphere.resources.vi_exception.VIException: [参数错误]: 'host' 应该是带有 ESX/VC url 的字符串。\n", "module_stdout": "", "msg": "MODULE FAILURE", "parsed": false}

为什么会出现这个错误?

【问题讨论】:

  • 这是什么,你对同一段代码的第八个问题?而且您还没有接受要求澄清的答案?

标签: ansible vmware ansible-playbook


【解决方案1】:

您当前正在向vsphere_guestguestvmware_guest_facts 提供两个参数。但是,the documentation 列出了更多需要的参数:

  • 密码
  • 用户名
  • vcenter_hostname

如果我不得不猜测,vcenter_hostname 默认为 None(Python 的 null 等效项),因此期望它是 URI 字符串的代码会抛出您在此处看到的异常。

【讨论】:

    猜你喜欢
    • 2021-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-12
    • 1970-01-01
    • 2014-04-27
    • 2013-09-14
    • 1970-01-01
    相关资源
    最近更新 更多