一段时间前,我已经创建了ansible剧本,用于通过ansible在我的homelab中为proxmox环境提供新的VM。问题是,在上周重新安装了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模板是我的模板,validationrun是新VM的名称。我检查了proxmox模块的官方ansible文档,并尝试了VM克隆的示例,但使用的是相同的错误-- https://docs.ansible.com/ansible/latest/collections/community/general/proxmox_kvm_module.html#examples
我尝试使用详细的参数运行剧本,但我得到的错误与我已经提到的基本相同(我隐藏了敏感内容):
<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')有人遇到过类似的问题吗?你知道怎么解决吗?几天来,我一直在努力寻找解决方案,但没有成功。
发布于 2022-03-09 14:18:56
这似乎是Proxmox_kvm Ansible模块中的一个bug。同样的代码我也有同样的问题。我发现了这个bugreport: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创建将按预期工作。
https://stackoverflow.com/questions/71402087
复制相似问题