community.general.linode inventory – 用于 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 中提供的所有信息填充主机变量。 选项 
 | |
| 根据变量的值将主机添加到组。 默认值:  | |
| 当主机变量的值为空字符串时的默认值。 此选项与  | |
| 用于生成组的输入字典中的键 | |
| 键控组的父组 | |
| 键控组名称将以此前缀开头 默认值:  | |
| 用于构建键控组名称的分隔符 默认值:  | |
| 将此选项设置为  此选项与  选项 
 | |
| 与 keyed_groups 结合使用。 默认情况下,没有提供前缀或分隔符的键控组的名称将以下划线开头。 这是因为默认前缀为 "",默认分隔符为 "_"。 如果未提供前缀,则将此选项设置为 False 可省略前导下划线(或其他分隔符)。 如果组名称是从映射派生的,则分隔符仍然用于连接项目。 要完全不在组名称中使用分隔符,请将键控组的分隔符设置为空字符串。 选项 
 | |
| 将此标记为“linode”插件的实例。 选项 
 | |
| 使用此区域中的实例填充清单。 默认值:  | |
| 如果为  由于可以在表达式中使用事实,它们可能并非总是可用,因此默认情况下我们会忽略这些错误。 选项 
 | |
| 仅使用至少具有此处列出的一个标签的实例填充清单。 默认值:  | |
| 使用此类型的实例填充清单。 默认值:  | |
| 将额外变量合并到可用于组合的变量中(优先级最高)。 选项 
 配置 
 | 
示例
# 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"
