community.general.proxmox inventory – Proxmox 清单源
注意
此清单插件是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。您需要进一步的要求才能使用此清单插件,有关详细信息,请参阅要求。
要在 playbook 中使用它,请指定:community.general.proxmox
。
community.general 1.2.0 中的新增功能
概要
从 Proxmox PVE 集群获取清单主机。
使用配置文件作为清单源,它必须以
.proxmox.yml
或.proxmox.yaml
结尾将检索 Proxmox 节点的第一个具有 IP 的网络接口。
可以将 LXC/QEMU 配置作为事实检索。
要求
以下要求需要在执行此清单的本地控制器节点上满足。
requests >= 1.1
参数
参数 |
注释 |
---|---|
切换以启用/禁用清单源数据的缓存,需要设置缓存插件才能工作。 选择
配置
|
|
缓存连接数据或路径,请阅读缓存插件文档以了解具体信息。 配置
|
|
用于清单源数据的缓存插件。 默认值: 配置
|
|
用于缓存插件文件/表的前缀。 默认值: 配置
|
|
缓存持续时间(秒)。 默认值: 配置
|
|
从 jinja2 表达式创建变量。 默认值: |
|
从清单输出中排除 proxmox 节点和 nodes-group。 选择
|
|
应用于 LXC/QEMU 配置事实的前缀。 默认值: |
|
允许过滤主机的一系列 Jinja 模板。 默认值: |
|
应用于 Proxmox 组的前缀。 默认值: |
|
根据 Jinja2 条件将主机添加到组。 默认值: |
|
基于变量的值将主机添加到组。 默认值: |
|
当主机变量的值为空字符串时的默认值。 此选项与 |
|
用于生成组的输入字典中的键。 |
|
键组的父组。 |
|
键组名称将以此前缀开头。 默认值: |
|
用于构建键组名称的分隔符。 默认值: |
|
将此选项设置为 此选项与 选择
|
|
与 默认情况下,没有提供前缀或分隔符的键组将使用以下划线开头的名称。 这是因为默认前缀是 如果未给出前缀,则将此选项设置为 如果组名称是从映射派生的,则仍然使用分隔符连接项目。 要完全不在组名称中使用分隔符,请将键组的分隔符设置为空字符串。 选择
|
|
Proxmox 身份验证密码。 如果未在清单配置中指定该值,则将使用环境变量 自 community.general 4.7.0 起,您还可以使用模板来指定 如果未指定密码,则必须设置 配置
|
|
此插件的名称,应始终设置为 选择
|
|
需要将 这将引入多个组 [前缀为 选择
|
|
如果为 由于可以在表达式中使用 facts,因此它们可能并非始终可用,并且我们默认忽略这些错误。 选择
|
|
Proxmox 身份验证令牌 ID。 如果未在清单配置中指定该值,则将使用环境变量 要使用令牌身份验证,您还必须指定 确保授予令牌显式的 pve 权限,或者禁用“特权隔离”以改为使用用户的特权。 配置
|
|
Proxmox 身份验证令牌密钥。 如果未在清单配置中指定该值,则将使用环境变量 要使用令牌身份验证,您还必须指定 配置
|
|
Proxmox 集群的 URL。 如果未在清单配置中指定该值,则将使用环境变量 自 community.general 4.7.0 起,您还可以使用模板来指定 默认值: 配置
|
|
将额外的变量合并到可用于合成的变量中(优先级最高)。 选择
配置
|
|
Proxmox 身份验证用户。 如果未在清单配置中指定该值,则将使用环境变量 自 community.general 4.7.0 起,您还可以使用模板来指定 配置
|
|
如果使用 HTTPS,则验证 SSL 证书。 选择
|
|
收集 LXC/QEMU 配置信息。 当 选择
|
|
是否为 proxmox 节点设置 设置为 此选项的默认值在 community.general 6.0.0 中从 选择
|
示例
# Minimal example which will not gather additional facts for QEMU/LXC guests
# By not specifying a URL the plugin will attempt to connect to the controller host on port 8006
# my.proxmox.yml
plugin: community.general.proxmox
user: ansible@pve
password: secure
# Note that this can easily give you wrong values as ansible_host. See further below for
# an example where this is set to `false` and where ansible_host is set with `compose`.
want_proxmox_nodes_ansible_host: true
# Instead of login with password, proxmox supports api token authentication since release 6.2.
plugin: community.general.proxmox
user: ci@pve
token_id: gitlab-1
token_secret: fa256e9c-26ab-41ec-82da-707a2c079829
# The secret can also be a vault string or passed via the environment variable TOKEN_SECRET.
token_secret: !vault |
$ANSIBLE_VAULT;1.1;AES256
62353634333163633336343265623632626339313032653563653165313262343931643431656138
6134333736323265656466646539663134306166666237630a653363623262636663333762316136
34616361326263383766366663393837626437316462313332663736623066656237386531663731
3037646432383064630a663165303564623338666131353366373630656661333437393937343331
32643131386134396336623736393634373936356332623632306561356361323737313663633633
6231313333666361656537343562333337323030623732323833
# More complete example demonstrating the use of 'want_facts' and the constructed options
# Note that using facts returned by 'want_facts' in constructed options requires 'want_facts=true'
# my.proxmox.yml
plugin: community.general.proxmox
url: http://pve.domain.com:8006
user: ansible@pve
password: secure
want_facts: true
keyed_groups:
# proxmox_tags_parsed is an example of a fact only returned when 'want_facts=true'
- key: proxmox_tags_parsed
separator: ""
prefix: group
groups:
webservers: "'web' in (proxmox_tags_parsed|list)"
mailservers: "'mail' in (proxmox_tags_parsed|list)"
compose:
ansible_port: 2222
# Note that this can easily give you wrong values as ansible_host. See further below for
# an example where this is set to `false` and where ansible_host is set with `compose`.
want_proxmox_nodes_ansible_host: true
# Using the inventory to allow ansible to connect via the first IP address of the VM / Container
# (Default is connection by name of QEMU/LXC guests)
# Note: my_inv_var demonstrates how to add a string variable to every host used by the inventory.
# my.proxmox.yml
plugin: community.general.proxmox
url: http://192.168.1.2:8006
user: ansible@pve
password: secure
validate_certs: false # only do this when you trust the network!
want_facts: true
want_proxmox_nodes_ansible_host: false
compose:
ansible_host: proxmox_ipconfig0.ip | default(proxmox_net0.ip) | ipaddr('address')
my_inv_var_1: "'my_var1_value'"
my_inv_var_2: >
"my_var_2_value"
# Specify the url, user and password using templating
# my.proxmox.yml
plugin: community.general.proxmox
url: "{{ lookup('ansible.builtin.ini', 'url', section='proxmox', file='file.ini') }}"
user: "{{ lookup('ansible.builtin.env','PM_USER') | default('ansible@pve') }}"
password: "{{ lookup('community.general.random_string', base64=True) }}"
# Note that this can easily give you wrong values as ansible_host. See further up for
# an example where this is set to `false` and where ansible_host is set with `compose`.
want_proxmox_nodes_ansible_host: true