回答Proxmox返回500错误

时间:2018-02-07 20:23:59

标签: ansible proxmox

我正在尝试使用Ansible在我新设置的Proxmox VE上配置一些虚拟机。我在本地Mac和Proxmox VE上安装了proxmoxer并请求PIP(Proxmox上的Python 2和本地Python 3)。我使用Ansible 2.4.3.0,Proxmox版本:5.1-41。

我确实有一个ID为100的虚拟机,它是从Debian模板创建的,虚拟机位于local-lvm (pve)

我的完整剧本可以在https://github.com/atwright147/ansible-contact-book-proxmox-provisioner找到,具体任务粘贴在下面:

---
- proxmox_kvm:
    api_user: root@pam
    api_password: REDACTED
    api_host: pve
    vmid: 100
    state: current

通过以下方式运行此脚本时:ansible-playbook -vvv --connection=local -i hosts site.yml我收到以下错误:

The full traceback is:
File "/tmp/ansible_TDEJsZ/ansible_module_proxmox_kvm.py", line 1227, in main
    current = getattr(proxmox.nodes(vm[0]['node']), VZ_TYPE)(vmid).status.current.get()['status']
File "/usr/local/lib/python2.7/dist-packages/proxmoxer/core.py", line 84, in get
    return self(args)._request("GET", params=params)
File "/usr/local/lib/python2.7/dist-packages/proxmoxer/core.py", line 79, in _request
    resp.content))

fatal: [192.168.0.22]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "acpi": true,
            "agent": null,
            "api_host": "pve",
            "api_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "api_user": "root@pam",
            "args": null,
            "autostart": false,
            "balloon": 0,
            "bios": null,
            "boot": "cnd",
            "bootdisk": null,
            "clone": null,
            "cores": 1,
            "cpu": "kvm64",
            "cpulimit": null,
            "cpuunits": 1000,
            "delete": null,
            "description": null,
            "digest": null,
            "force": null,
            "format": "qcow2",
            "freeze": null,
            "full": true,
            "hostpci": null,
            "hotplug": null,
            "hugepages": null,
            "ide": null,
            "keyboard": null,
            "kvm": true,
            "localtime": null,
            "lock": null,
            "machine": null,
            "memory": 512,
            "migrate_downtime": null,
            "migrate_speed": null,
            "name": null,
            "net": null,
            "newid": null,
            "node": null,
            "numa": null,
            "numa_enabled": null,
            "onboot": true,
            "ostype": "l26",
            "parallel": null,
            "pool": null,
            "protection": null,
            "reboot": null,
            "revert": null,
            "sata": null,
            "scsi": null,
            "scsihw": null,
            "serial": null,
            "shares": null,
            "skiplock": null,
            "smbios": null,
            "snapname": null,
            "sockets": 1,
            "startdate": null,
            "startup": null,
            "state": "current",
            "storage": null,
            "tablet": false,
            "target": null,
            "tdf": null,
            "template": false,
            "timeout": 30,
            "update": false,
            "validate_certs": false,
            "vcpus": null,
            "vga": "std",
            "virtio": null,
            "vmid": 100,
            "watchdog": null
        }
    },
    "msg": "Unable to get vm None with vmid = 100 status: 500 Internal Server Error: {\"data\":null}"
}

Ansible info:

ansible 2.4.3.0
  config file = /Users/andy/Development/proxmox-playbooks/contact-book/ansible.cfg
  configured module search path = ['/Users/andy/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.4 (default, Jan 25 2018, 18:48:20) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.38)]

我做错了什么?

1 个答案:

答案 0 :(得分:3)

原来我在这里犯了几个错误。

  1. 我应该使用proxmox模块而不是proxmox_kvm
  2. 我需要使用存储参数在local-lvm中设置容器,例如storage: local-lvm
  3. 我的最终工作任务如下:

    - name: "Create a Linux Container (LXC)"
      proxmox:
        node: pve
        api_user: root@pam
        api_password: proxmox_password
        api_host: pve
        password: vm_password
        hostname: vm.hostname.local
        ostemplate: "local:vztmpl/ubuntu-16.04-standard_16.04-1_amd64.tar.gz"
        storage: local-lvm
        cores: 2
        state: present