0

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

我确实有一个 id 为 100 的 vm,它是从 Debian 模板创建的,该 vm 位于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信息:

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)]

我究竟做错了什么?

4

1 回答 1

3

事实证明,我在这里犯了几个错误。

  1. 我应该一直在使用proxmox模块而不是proxmox_kvm
  2. 我需要使用存储参数来设置容器,local-lvm例如storage: local-lvm

我的最终工作任务如下所示:

- 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
于 2018-02-11T15:56:29.880 回答