community.general.ipa_host 模块 – 管理 FreeIPA 主机

注意

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

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

要安装它,请使用: ansible-galaxy collection install community.general

要在剧本中使用它,请指定: community.general.ipa_host

概要

  • 使用 IPA API 添加、修改和删除 IPA 主机。

参数

参数

注释

description

字符串

此主机的描述。

force

布尔值

即使主机名不在 DNS 中,也强制使用主机名。

选项

  • false

  • true

force_creation

布尔值

在 community.general 9.5.0 中添加

如果 state=disabledstate=enabled 但不存在,则创建主机。

选项

  • false

  • true ← (默认)

fqdn

别名:name

字符串 / 必需

完全限定域名。

不能更改,因为它是一个唯一的标识符。

ip_address

字符串

使用此 IP 地址将主机添加到 DNS。

ipa_host

字符串

IPA 服务器的 IP 或主机名。

如果任务中未指定此值,则将使用环境变量 IPA_HOST 的值。

如果任务中既未指定环境变量 IPA_HOST,也未指定值,则将使用 DNS 来尝试发现 FreeIPA 服务器。

FreeIPA 中所需的相应条目是 ipa-ca 条目。

如果任务中既没有 DNS 条目,也没有环境变量 IPA_HOST,也没有值,则将使用默认值。

默认值: "ipa.example.com"

ipa_pass

字符串

管理员用户的密码。

如果任务中未指定此值,则将使用环境变量 IPA_PASS 的值。

请注意,如果 urllib_gssapi 库可用,则可以使用 GSSAPI 进行 FreeIPA 身份验证。

如果环境变量 KRB5CCNAME 可用,则模块将使用此 Kerberos 凭据缓存来对 FreeIPA 服务器进行身份验证。

如果环境变量 KRB5_CLIENT_KTNAME 可用,而 KRB5CCNAME 不可用;模块将使用此 Kerberos 密钥表进行身份验证。

如果 GSSAPI 不可用,则需要使用 ipa_pass

ipa_port

整数

FreeIPA/IPA 服务器的端口。

如果任务中未指定此值,则将使用环境变量 IPA_PORT 的值。

如果任务中既未指定环境变量 IPA_PORT,也未指定值,则将设置默认值。

默认值: 443

ipa_prot

字符串

IPA 服务器使用的协议。

如果任务中未指定此值,则将使用环境变量 IPA_PROT 的值。

如果任务中既未指定环境变量 IPA_PROT,也未指定值,则将设置默认值。

选项

  • "http"

  • "https" ← (默认)

ipa_timeout

整数

指定连接的空闲超时(以秒为单位)。

对于批量操作,您可能需要增加此值以避免 IPA 服务器超时。

如果任务中未指定此值,则将使用环境变量 IPA_TIMEOUT 的值。

如果任务中既未指定环境变量 IPA_TIMEOUT,也未指定值,则将设置默认值。

默认值: 10

ipa_user

字符串

在 IPA 服务器上使用的管理员帐户。

如果任务中未指定此值,则将使用环境变量 IPA_USER 的值。

如果任务中未指定环境变量IPA_USER及其值,则将设置默认值。

默认值: "admin"

mac_address

别名:macaddress

列表 / 元素=字符串

此主机的硬件MAC地址列表。

如果省略此选项,则不会检查或更改MAC地址。

如果传递空列表,则将删除所有已分配的MAC地址。

已分配但未传递的MAC地址将被删除。

ns_hardware_platform

别名:nshardwareplatform

字符串

主机硬件平台(例如,“Lenovo T61”)

ns_host_location

别名:nshostlocation

字符串

主机位置(例如,“实验室2”)

ns_os_version

别名:nsosversion

字符串

主机操作系统和版本(例如,“Fedora 9”)

random_password

布尔值

生成一个用于批量注册的随机密码。

选项

  • false

  • true

state

字符串

要确保的状态。

选项

  • "absent"

  • "disabled"

  • "enabled"

  • "present" ← (默认)

update_dns

布尔值

如果与state=absent一起设置为true,则删除由FreeIPA DNS管理的主机的DNS记录。

此选项对“absent”以外的状态无效。

选项

  • false

  • true

user_certificate

别名:usercertificate

列表 / 元素=字符串

Base-64编码的服务器证书列表。

如果省略此选项,则不会检查或更改证书。

如果传递空列表,则将删除所有已分配的证书。

已分配但未传递的证书将被删除。

validate_certs

布尔值

这仅在ipa_prothttps时适用。

如果设置为false,则不会验证SSL证书。

仅应在使用自签名证书的个人控制站点上将其设置为false

选项

  • false

  • true ← (默认)

属性

属性

支持

描述

check_mode

支持:完全支持

可以在check_mode下运行,并在不修改目标的情况下返回更改状态预测。

diff_mode

支持:不支持

在差异模式下,将返回有关已更改内容(或可能需要在check_mode下更改的内容)的详细信息。

示例

- name: Ensure host is present
  community.general.ipa_host:
    name: host01.example.com
    description: Example host
    ip_address: 192.168.0.123
    ns_host_location: Lab
    ns_os_version: CentOS 7
    ns_hardware_platform: Lenovo T61
    mac_address:
    - "08:00:27:E3:B1:2D"
    - "52:54:00:BD:97:1E"
    state: present
    ipa_host: ipa.example.com
    ipa_user: admin
    ipa_pass: topsecret

- name: Generate a random password for bulk enrolment
  community.general.ipa_host:
    name: host01.example.com
    description: Example host
    ip_address: 192.168.0.123
    state: present
    ipa_host: ipa.example.com
    ipa_user: admin
    ipa_pass: topsecret
    random_password: true

- name: Ensure host is disabled
  community.general.ipa_host:
    name: host01.example.com
    state: disabled
    ipa_host: ipa.example.com
    ipa_user: admin
    ipa_pass: topsecret

- name: Ensure that all user certificates are removed
  community.general.ipa_host:
    name: host01.example.com
    user_certificate: []
    ipa_host: ipa.example.com
    ipa_user: admin
    ipa_pass: topsecret

- name: Ensure host is absent
  community.general.ipa_host:
    name: host01.example.com
    state: absent
    ipa_host: ipa.example.com
    ipa_user: admin
    ipa_pass: topsecret

- name: Ensure host and its DNS record is absent
  community.general.ipa_host:
    name: host01.example.com
    state: absent
    ipa_host: ipa.example.com
    ipa_user: admin
    ipa_pass: topsecret
    update_dns: true

返回值

常见返回值已在此处记录,以下是此模块独有的字段

描述

host

字典

IPA API返回的主机。

返回值:始终返回

host_diff

列表 / 元素=字符串

差异并会更改的选项列表

返回值:如果处于检查模式且发现差异

作者

  • Thomas Krahn (@Nosmoht)