【问题标题】:Ansible - Build dynamic inventory with proxmoxAnsible - 使用 proxmox 构建动态库存
【发布时间】:2022-11-17 03:02:12
【问题描述】:

我想由 Proxmox 生成的动态清单有问题。我创建了一个 inventory.proxmox.yml 文件。这包含以下配置:

plugin: community.general.proxmox
url: https://MyIP:8006
user: ansible@pve
password: my_password
validate_certs: false
want_proxmox_nodes_ansible_host: false

在下一步中,我想创建库存。为此,我进行如下操作:

ansible-inventory -i inventory.proxmox.yml --list

执行后,我收到以下错误:

/usr/lib/python3/dist-packages/urllib3/connectionpool.py:1015: InsecureRequestWarning: Unverified HTTPS request is being made to host 'myIP'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  warnings.warn(
[WARNING]:  * Failed to parse /home/user/ansible/inventory/inventory.proxmox.yml with auto plugin: 'NoneType' object is not subscriptable
[WARNING]:  * Failed to parse /home/user/ansible/inventory/inventory.proxmox.yml with yaml plugin: Plugin configuration YAML file, not YAML inventory
[WARNING]:  * Failed to parse /home/user/ansible/inventory/inventory.proxmox.yml with ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not
allowed, this character is reserved to provide a port.
[WARNING]:  * Failed to parse /home/user/ansible/inventory/inventory.proxmox.yml with ansible_collections.community.general.plugins.inventory.proxmox plugin:
'NoneType' object is not subscriptable
[WARNING]: Unable to parse /home/user/ansible/inventory/inventory.proxmox.yml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available

将我的 yml 文件中的“url: https”更改为“http”确实摆脱了 https 错误。但是,proxmox 没有在 http 上监听。

【问题讨论】:

  • 我不明白。库存从哪里获得?来自 proxmox?还是您手动配置库存?
  • 您好,我已经手动创建了库存。但是,目标是从 proxmox 读取所有现有的 VM,包括主机名/IP,并将它们用作清单。
  • 为什么?您会经常构建/破坏虚拟机吗?为什么不在清单文件中配置一次呢?

标签: ansible proxmox


【解决方案1】:

我有一个类似的问题:

[WARNING]:  * Failed to parse pve.yml with auto plugin: inventory source 'pve.yml' could not be verified by inventory plugin 'community.general.proxmox'
[WARNING]:  * Failed to parse pve.yml with yaml plugin: Plugin configuration YAML file, not YAML inventory
[WARNING]:  * Failed to parse pve.yml with ini plugin: Invalid host pattern 'plugin:' supplied, ending in ':' is not allowed, this character is reserved to provide a port.
[WARNING]: Unable to parse pve.yml as an inventory source
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'
[WARNING]: Could not match supplied host pattern, ignoring: pve

事实证明这个问题相当愚蠢和出乎意料。我进入了模块本身的代码并发现了这个:

self.display.vvv('Skipping due to inventory source not ending in "proxmox.yaml" nor "proxmox.yml"')

所以我只是将我的库存文件重命名为proxmox.yml并且它起作用了。 我的库存:

plugin: community.general.proxmox
url: https://my.pve.host:8006
user: ansible-prov@pve
token_id: ansible
token_secret: <token>
validate_certs: false
want_proxmox_nodes_ansible_host: false
compose:
  ansible_host: proxmox_ipconfig0.ip | default(proxmox_net0.ip) | ipaddr('address')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-24
    • 1970-01-01
    相关资源
    最近更新 更多