community.general.linode 清单 – 用于 Linode 的 Ansible 动态清单插件。
注意
此清单插件是 community.general 集合(版本 10.1.0)的一部分。
如果您使用的是 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。您需要其他要求才能使用此清单插件,请参阅 要求 了解详情。
要在 playbook 中使用它,请指定:community.general.linode
。
概要
从 Linode API v4 读取清单。
使用以 linode.(yml|yaml) 结尾的 YAML 配置文件。
默认情况下,Linode 标签用作主机名。
默认清单组是从组(Linode 已弃用)而不是标签构建的。
要求
本地控制器节点(执行此清单)需要以下要求。
linode_api4 >= 2.0.0
参数
参数 |
注释 |
---|---|
切换以启用/禁用清单源数据的缓存,需要设置缓存插件才能工作。 选项
配置
|
|
缓存连接数据或路径,请阅读缓存插件文档以了解具体信息。 配置
|
|
用于清单源数据的缓存插件。 默认: 配置
|
|
用于缓存插件文件/表的前缀。 默认: 配置
|
|
缓存持续时间(以秒为单位)。 默认: 配置
|
|
从 jinja2 表达式创建变量。 默认: |
|
根据 Jinja2 条件将主机添加到组。 默认: |
|
使用 Linode APIv4 中提供的所有信息填充 hostvars。 选项
|
|
根据变量的值将主机添加到组。 默认: |
|
当主机变量的值为空字符串时的默认值。 此选项与 |
|
用于生成组的输入字典中的键。 |
|
键控组的父组。 |
|
键控组名称将以此前缀开头。 默认值: |
|
用于构建键控组名称的分隔符。 默认值: |
|
将此选项设置为 此选项与 选项
|
|
与 默认情况下,没有提供前缀或分隔符的键控组的名称将以下划线开头。 这是因为默认前缀是 如果未给出前缀,请将此选项设置为 如果组名称是从映射派生的,则分隔符仍用于连接各项。 要完全不在组名称中使用分隔符,请将键控组的分隔符设置为空字符串。 选项
|
|
将此标记为“linode”插件的实例。 选项
|
|
使用此区域中的实例填充清单。 默认: |
|
如果 由于可以在表达式中使用 facts,因此它们可能并非始终可用,默认情况下我们会忽略这些错误。 选项
|
|
仅使用此处列出的至少一个标签的实例填充清单。 默认: |
|
使用此类型的实例填充清单。 默认: |
|
将额外的变量合并到可用于组合的变量中(优先级最高)。 选项
配置
|
示例
# Minimal example. `LINODE_ACCESS_TOKEN` is exposed in environment.
plugin: community.general.linode
# You can use Jinja to template the access token.
plugin: community.general.linode
access_token: "{{ lookup('ini', 'token', section='your_username', file='~/.config/linode-cli') }}"
# For older Ansible versions, you need to write this as:
# access_token: "{{ lookup('ini', 'token section=your_username file=~/.config/linode-cli') }}"
# Example with regions, types, groups and access token
plugin: community.general.linode
access_token: foobar
regions:
- eu-west
types:
- g5-standard-2
# Example with keyed_groups, groups, and compose
plugin: community.general.linode
access_token: foobar
keyed_groups:
- key: tags
separator: ''
- key: region
prefix: region
groups:
webservers: "'web' in (tags|list)"
mailservers: "'mail' in (tags|list)"
compose:
# By default, Ansible tries to connect to the label of the instance.
# Since that might not be a valid name to connect to, you can
# replace it with the first IPv4 address of the linode as follows:
ansible_ssh_host: ipv4[0]
ansible_port: 2222
# Example where control traffic limited to internal network
plugin: community.general.linode
access_token: foobar
ip_style: api
compose:
ansible_host: "ipv4 | community.general.json_query('[?public==`false`].address') | first"