community.general.nomad_token 模块 – 管理 Nomad ACL 令牌

注意

此模块是 community.general 集合(版本 10.1.0)的一部分。

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

要安装它,请使用:ansible-galaxy collection install community.general。您需要进一步的要求才能使用此模块,有关详细信息,请参阅 要求

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

community.general 8.1.0 中的新增功能

概要

  • 此模块允许创建引导令牌、创建 ACL 令牌、更新 ACL 令牌和删除 ACL 令牌。

要求

执行此模块的主机上需要满足以下要求。

  • python-nomad

参数

参数

注释

client_cert

路径

TLS/SSL 证书的路径。

client_key

路径

TLS/SSL 证书私钥的路径。

global_replicated

布尔值

指示令牌是否使用 --global 创建。

选择

  • false ← (默认)

  • true

host

字符串 / 必需

Nomad 服务器的 FQDN。

name

字符串

要创建的 ACL 令牌的名称。

namespace

字符串

Nomad 的命名空间。

policies

列表 / elements=字符串

分配给令牌的策略列表。

默认值: []

port

整数

在 community.general 8.0.0 中添加

Nomad 服务器的端口。

默认值: 4646

state

字符串 / 必需

创建或删除 ACL 令牌。

选择

  • "present"

  • "absent"

timeout

整数

向 Nomad 发送请求的超时时间(以秒为单位)。

默认值: 5

token

字符串

用于身份验证的 ACL 令牌。

token_type

字符串

令牌的类型可以是 clientmanagementbootstrap

选择

  • "client" ← (默认)

  • "management"

  • "bootstrap"

use_ssl

布尔值

使用 TLS/SSL 连接。

选择

  • false

  • true ← (默认)

validate_certs

布尔值

启用 TLS/SSL 证书验证。

选择

  • false

  • true ← (默认)

属性

属性

支持

描述

check_mode

支持:

可以在 check_mode 中运行并返回更改状态预测,而无需修改目标。

diff_mode

支持:

当处于 diff 模式时,将返回有关已更改的内容(或在 check_mode 中可能需要更改的内容)的详细信息。

另请参阅

另请参阅

Nomad ACL 文档

Nomad API ACL 的完整文档。

示例

- name: Create boostrap token
  community.general.nomad_token:
    host: localhost
    token_type: bootstrap
    state: present

- name: Create ACL token
  community.general.nomad_token:
    host: localhost
    name: "Dev token"
    token_type: client
    policies:
        - readonly
    global_replicated: false
    state: absent

- name: Update ACL token Dev token
  community.general.nomad_token:
    host: localhost
    name: "Dev token"
    token_type: client
    policies:
        - readonly
        - devpolicy
    global_replicated: false
    state: absent

- name: Delete ACL token
  community.general.nomad_token:
    host: localhost
    name: "Dev token"
    state: absent

返回值

常见的返回值记录在 这里,以下是此模块特有的字段

描述

result

字典

Nomad 返回的结果。

返回: 始终

示例: {"accessor_id": "0d01c55f-8d63-f832-04ff-1866d4eb594e", "create_index": 14, "create_time": "2023-11-12T18:48:34.248857001Z", "expiration_time": null, "expiration_ttl": "", "global": true, "hash": "eSn8H8RVqh8As8WQNnC2vlBRqXy6DECogc5umzX0P30=", "modify_index": 836, "name": "devs", "policies": ["readonly"], "roles": null, "secret_id": "12e878ab-e1f6-e103-b4c4-3b5173bb4cea", "type": "client"}

作者

  • Pedro Nascimento (@apecnascimento)