Ansible proxmox 剧本因未知原因停止工作

Ansible proxmox playbook stopped working for unknown reason

前段时间我创建了 ansible playbook,用于通过 ansible 在我的 homelab 中为 proxmox 环境配置新的虚拟机。问题是,在上周重新安装我的 proxmox 节点后,负责克隆我的 debian 模板的 ansible 剧本由于某种原因停止工作。

我的剧本是这样的:

- name: 010-cloning
  hosts: "{{ default_PVE }}"
  user: root
  gather_facts: false
  vars:
    PVE_node: ""
    VM_name: ""
    VM_template: ""
    PV_user: ""
    PV_password: ""
    default_PVE: ""

  tasks:
  - name: Cloning VM from "{{ VM_template }}" with name "{{ VM_name }}"
    proxmox_kvm:
        api_user : "{{ PV_user }}"
        api_password: "{{ PV_password }}"
        api_host : "{{ PVE_node }}"
        clone: "{{ VM_template }}"
        name : "{{ VM_name }}"
        node : "{{ default_PVE }}"

由于某些未知原因,我收到此错误:

TASK [Cloning VM from "debian-11-template" with name "validationrun"] *****************************************************************************************************************************************************************************************************************
fatal: [prox1]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"}, "changed": false, "msg": "No VM with name validationrun found"}

其中 prox1 是我的 proxmox 节点,debian-11-template 是我的模板,validation运行 是新虚拟机的名称。我已经检查了 proxmox 模块的官方 ansible 文档,并且尝试了 VM 克隆的示例,但出现了同样的错误 - https://docs.ansible.com/ansible/latest/collections/community/general/proxmox_kvm_module.html#examples

我已经尝试 运行 使用详细参数的 playbook,但我遇到的错误与我已经提到的基本相同(我隐藏了敏感内容):

<XXX.XXX.XXX.XXX> (1, b'\r\n{"failed": true, "msg": "No VM with name validationrun found", "invocation": {"module_args": {"api_user": "XXX", "api_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "api_host": "prox1", "clone": "debian-11-template", "name": "validationrun", "node": "prox1", "validate_certs": false, "full": true, "state": "present", "timeout": 30, "update": false, "proxmox_default_behavior": "no_defaults", "api_token_id": null, "api_token_secret": null, "acpi": null, "agent": null, "args": null, "autostart": null, "balloon": null, "bios": null, "boot": null, "bootdisk": null, "cicustom": null, "cipassword": null, "citype": null, "ciuser": null, "cores": null, "cpu": null, "cpulimit": null, "cpuunits": null, "delete": null, "description": null, "digest": null, "efidisk0": null, "force": null, "format": null, "freeze": null, "hostpci": null, "hotplug": null, "hugepages": null, "ide": null, "ipconfig": null, "keyboard": null, "kvm": null, "localtime": null, "lock": null, "machine": null, "memory": null, "migrate_downtime": null, "migrate_speed": null, "nameservers": null, "net": null, "newid": null, "numa": null, "numa_enabled": null, "onboot": null, "ostype": null, "parallel": null, "pool": null, "protection": null, "reboot": null, "revert": null, "sata": null, "scsi": null, "scsihw": null, "serial": null, "searchdomains": null, "shares": null, "skiplock": null, "smbios": null, "snapname": null, "sockets": null, "sshkeys": null, "startdate": null, "startup": null, "storage": null, "tablet": null, "tags": null, "target": null, "tdf": null, "template": null, "vcpus": null, "vga": null, "virtio": null, "vmid": null, "watchdog": null}}}\r\n', b'Shared connection to XXX.XXX.XXX.XXX closed.\r\n')

有人遇到过类似的问题吗?或者您知道如何解决吗?这几天我一直在尝试寻找解决方案,但没有成功。

这似乎是 Proxmox_kvm Ansible 模块中的错误。我对相同的代码有同样的问题。 我发现了这个错误报告:https://github.com/ansible-collections/community.general/issues/4278,修复已经合并但尚未发布。

同时,我按照本手册安装 Ansible community.general 集合来修复此问题:https://docs.ansible.com/ansible/latest/user_guide/collections_using.html#installing-a-collection-from-a-git-repository

要检查集合的最新提交,运行:

ansible-galaxy collection install git+https://github.com/ansible-collections/community.general.git,main

之后 VM 创建按预期进行。