community.general.gitlab_runners inventory – GitLab Runner 的 Ansible 动态 Inventory 插件。

注意

此 Inventory 插件是 community.general 集合 (版本 10.1.0) 的一部分。

如果您使用的是 ansible 包,则可能已安装此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install community.general。您需要其他要求才能使用此 Inventory 插件,有关详细信息,请参见 要求

要在 playbook 中使用它,请指定:community.general.gitlab_runners

概要

  • 从 GitLab API 读取清单。

  • 使用 YAML 配置文件 gitlab_runners.[yml|yaml]。

要求

以下要求在执行此清单的本地控制器节点上是必需的。

  • python-gitlab > 1.8.0

参数

参数

注释

api_token

别名:private_token,access_token

字符串

用于登录的 GitLab 令牌。

配置

compose

字典

从 jinja2 表达式创建变量。

默认值: {}

filter

字符串

从 GitLab API 过滤 Runner

选项

  • "active"

  • "paused"

  • "online"

  • "specific"

  • "shared"

配置

  • 环境变量:GITLAB_FILTER

    在 community.general 1.0.0 中添加

groups

字典

基于 Jinja2 条件将主机添加到组。

默认值: {}

keyed_groups

列表 / 元素=字典

基于变量的值将主机添加到组。

默认值: []

default_value

字符串

在 ansible-core 2.12 中添加

主机变量的值为空字符串时的默认值。

此选项与 keyed_groups[].trailing_separator 互斥。

key

字符串

用于生成组的输入字典中的键。

parent_group

字符串

键控组的父组。

prefix

字符串

键控组名称将以此前缀开头。

默认值: ""

separator

字符串

用于构建键控组名称的分隔符。

默认值: "_"

trailing_separator

布尔值

在 ansible-core 2.12 中添加

将此选项设置为 false 以在值为空字符串时省略 keyed_groups[].separator

此选项与 keyed_groups[].default_value 互斥。

选项

  • false

  • true ← (默认)

leading_separator

布尔值

在 ansible-core 2.11 中添加

keyed_groups 结合使用。

默认情况下,未提供前缀或分隔符的键控组的名称将以下划线开头。

这是因为默认前缀为 "",默认分隔符为 "_"

如果未给出前缀,则将此选项设置为 false 以省略前导下划线(或其他分隔符)。

如果组名来自映射,则分隔符仍用于连接项目。

要根本不使用组名中的分隔符,请将键控组的分隔符设置为空字符串。

选项

  • false

  • true ← (默认)

plugin

字符串 / 必需

此插件的名称,对于此插件将其识别为自身,应始终设置为“gitlab_runners”。

选项

  • "gitlab_runners"

  • "community.general.gitlab_runners"

server_url

字符串 / 必需

GitLab 服务器的 URL,包含协议(即 http 或 https)。

配置

严格模式

布尔值

如果为yes,则将无效条目视为致命错误;否则跳过并继续。

由于表达式中可以使用facts,因此它们可能并不总是可用,我们默认忽略这些错误。

选项

  • false ← (默认)

  • true

use_extra_vars

布尔值

在 ansible-core 2.11 中添加

将额外的变量合并到可用于组合的变量中(最高优先级)。

选项

  • false ← (默认)

  • true

配置

详细输出

布尔值

切换是否包含所有可用的节点元数据

选项

  • false

  • true ← (默认)

示例

# gitlab_runners.yml
plugin: community.general.gitlab_runners
host: https://gitlab.com

# Example using constructed features to create groups and set ansible_host
plugin: community.general.gitlab_runners
host: https://gitlab.com
strict: false
keyed_groups:
  # add e.g. amd64 hosts to an arch_amd64 group
  - prefix: arch
    key: 'architecture'
  # add e.g. linux hosts to an os_linux group
  - prefix: os
    key: 'platform'
  # create a group per runner tag
  # e.g. a runner tagged w/ "production" ends up in group "label_production"
  # hint: labels containing special characters will be converted to safe names
  - key: 'tag_list'
    prefix: tag

作者

  • Stefan Heitmüller (@morph027)

提示

每个条目类型的配置项具有从低到高的优先级顺序。例如,列表中较低的变量将覆盖较高的变量。