community.dns.hosttech_dns_records 资产清单 – 从 Hosttech DNS 记录创建资产清单

注意

此资产清单插件是 community.dns 集合(版本 3.1.0)的一部分。

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

要安装它,请使用:ansible-galaxy collection install community.dns。您需要进一步的要求才能使用此资产清单插件,有关详细信息,请参阅 要求

要在 playbook 中使用它,请指定:community.dns.hosttech_dns_records

community.dns 2.0.0 中的新增功能

概要

  • 为了使 Ansible 能够将 YAML 文件识别为该插件的资产清单,资产清单文件必须包含 plugin: community.dns.hosttech_dns_records,并且其文件名必须以 hosttech_dns.yamlhosttech_dns.yml 结尾。

  • 记录通过前缀/记录名称和值匹配。

  • 此插件允许从 Hosttech DNS 记录创建资产清单。

要求

以下要求需要在执行此资产清单的本地控制器节点上满足。

  • lxml

参数

参数

注释

filters

列表 / 元素=字典

在 community.dns 3.0.0 中添加

允许为此资产清单选择/取消选择主机的包含/排除过滤器列表。

过滤器会按顺序处理,直到找到第一个匹配 filters[].excludefilters[].include 的过滤器。如果 filters[].exclude 匹配,则会排除主机;如果 filters[].include 匹配,则会包含主机。如果没有任何过滤器匹配,则会包含主机。

exclude

字符串

Jinja2 条件。如果它与主机匹配,则会排除该主机。

只能指定 filters[].excludefilters[].include 中的一个。

include

字符串

Jinja2 条件。如果它与主机匹配,则会包含该主机。

只能指定 filters[].excludefilters[].include 中的一个。

hosttech_password

字符串

Hosttech API 用户的密码。

如果提供,则还必须提供 hosttech_username

hosttech_token 互斥。

配置

hosttech_token

别名:api_token

字符串

在 community.dns 0.2.0 中添加

Hosttech API 用户的密码。

hosttech_usernamehosttech_password 互斥。

自 community.dns 1.2.0 起,可以使用别名 api_token

配置

hosttech_username

字符串

Hosttech API 用户的用户名。

如果提供了 hosttech_password,则必须同时提供 hosttech_password

hosttech_token 互斥。

配置

插件

字符串 / 必需

此插件的名称。为了让此插件识别它自身,应始终设置为 community.dns.hosttech_dns_records

选项

  • "community.dns.hosttech_dns_records"

simple_filters

字典

过滤器值对的字典。

此选项在 community.dns 3.0.0 之前称为 filters。它在 community.dns 2.8.0 中从 filters 重命名为 simple_filters,旧名称在 community.dns 3.0.0 之前仍然可用作别名。filters 现在用于其他用途。

默认值: {}

类型

列表 / 元素=字符串

要使用的记录类型的值。

选项

  • "A" ← (默认)

  • "AAAA" ← (默认)

  • "CAA"

  • "CNAME" ← (默认)

  • "MX"

  • "NS"

  • "PTR"

  • "SPF"

  • "SRV"

  • "TXT"

默认值: ["A", "AAAA", "CNAME"]

txt_character_encoding

字符串

在 community.dns 2.5.0 中添加

是否将数字转义序列(\xyz)视为八进制或十进制数字。仅当 txt_transformation=quoted 时使用。

默认值在 community.dns 3.0.0 中更改为 decimal。之前,默认值是 octaldecimal 值与 RFC 1035 兼容。

选项

  • "decimal" ← (默认)

  • "octal"

txt_transformation

字符串

确定如何在 API 和此模块的输入和输出之间转换 TXT 条目值。

api 表示值从此模块返回时与从 API 返回的值相同,并且推送至 API 的值与传递给此模块的值相同。对于幂等性检查,输入字符串将与 API 返回的字符串进行比较。API 可能会自动转换一些值,例如拆分长值或添加引号,这可能会导致幂等性问题。

unquoted 自动转换值,以便您可以传入未加引号的值,并且模块将返回未加引号的值。如果传入加引号的值,它们将被双引号引起来。

quoted 自动转换值,以便您必须对包含空格、引号和反斜杠等字符且长度超过 255 字节的值使用引号。它还确保以规范化的编码返回 API 中的值。

默认值 unquoted 确保您可以使用值,而无需关心如何正确地为 DNS 加引号。大多数用户应该使用 unquotedquoted 之一,而不是 api

注意:转换代码假定值为 UTF-8 编码。如果需要其他编码,请使用 txt_transformation=api 并自行处理编码。

选项

  • "api"

  • "quoted"

  • "unquoted" ← (默认)

zone_id

任意

要修改的 DNS 区域的 ID。

必须指定 zone_namezone_id 中的一个。

zone_name

别名: zone

字符串

要修改的 DNS 区域。

必须指定 zone_namezone_id 中的一个。

备注

注意

另请参阅

另请参阅

community.dns.hosttech_dns_record_set_info

检索 Hosttech DNS 服务中的记录集。

community.dns.hosttech_dns_record_info

检索 Hosttech DNS 服务中的记录。

示例

# filename must end with hosttech_dns.yaml or hosttech_dns.yml

plugin: community.dns.hosttech_dns_records
zone_name: domain.ch
simple_filters:
  type:
    - AAAA
filters:
  - include: >-
      '*.' not in inventory_hostname
  - exclude: true

# You can also configure the token by putting secret value into this file,
# but this is discouraged. Use a lookup like below, or leave it away and
# set it with the ANSIBLE_HOSTTECH_DNS_TOKEN environment variable.
hosttech_token: >-
    {{ (lookup('community.sops.sops', 'keys/hosttech.sops.yml') | from_yaml).hosttech_dns_token }}

作者

  • Markus Bergholz (@markuman)

  • Felix Fontein (@felixfontein)

提示

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