community.windows.laps_password 查询 – 获取服务器的 LAPS 密码。
注意
此查询插件是 community.windows 集合 (版本 2.3.0) 的一部分。
如果您使用的是 ansible
包,则可能已安装此集合。它不包含在 ansible-core
中。要检查它是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.windows
。您需要其他要求才能使用此查询插件,请参阅 要求 获取详细信息。
要在 playbook 中使用它,请指定:community.windows.laps_password
。
概要
此查询返回从 Active Directory 数据库中为服务器设置的 LAPS 密码。
有关安装先决条件和测试的更多信息,请参见 https://github.com/jborean93/ansible-lookup-laps_password。
要求
以下要求是在执行此查询的本地控制器节点上需要的。
python-ldap
术语
参数 |
注释 |
---|---|
要为其检索 LAPS 密码的主机名。 这是主机的 |
关键字参数
这描述了查询的关键字参数。这些是在以下示例中的值 key1=value1
,key2=value2
等:lookup('community.windows.laps_password', key1=value1, key2=value2, ...)
和 query('community.windows.laps_password', key1=value1, key2=value2, ...)
参数 |
注释 |
---|---|
设置为 强烈建议不要修改此设置,以避免任何凭据在网络流量中暴露。 使用 选项
|
|
连接到 Active Directory 服务器时要使用的身份验证类型 使用 建议使用 使用 当设置 选项
|
|
要用于证书验证的 CA 证书 PEM 文件的路径。 当 这可能会在具有较旧 OpenLDAP 安装(如 MacOS)的主机上失败,这将必须在重新安装 python-ldap 之前更新才能再次工作。 |
|
要从中检索 LAPS 密码的域。 这可以是 Ansible 控制器从 DNS 中看到的 Windows 域名,也可以是特定的域控制器 FQDN。 支持仅域名/主机名或已填充域名/主机的显式 LDAP URI。 如果设置了 URI,则忽略 *端口* 和 *方案*。 |
|
当设置 |
|
要通过其通信的 LDAP 端口。 如果kdc已经是LDAP URI,则忽略此设置。 |
|
要使用的LDAP方案。 使用 必须先为Active Directory主机配置具有证书的 如果kdc已经是LDAP URI,则忽略此设置。 选项
|
|
更改在Active Directory中搜索主机时使用的搜索基础。 默认为在Active Directory服务器的 如果找到多个匹配项,则需要更明确的search_base,以便只找到1个主机。 如果搜索较大的Active Directory数据库,建议出于性能原因缩小search_base。 |
|
当 这需要Active Directory使用支持StartTLS的证书进行设置。 当 选项
|
|
使用 用于身份验证的用户名。 建议使用UPN格式的用户名,例如 当 如果需要 |
|
使用
选项
|
备注
注意
当关键字参数和位置参数一起使用时,位置参数必须列在关键字参数之前:
lookup('community.windows.laps_password', term1, term2, key1=value1, key2=value2)
和query('community.windows.laps_password', term1, term2, key1=value1, key2=value2)
如果找到主机但没有LAPS密码属性
ms-Mcs-AdmPwd
,则查找将失败。由于通过网络传输的数据的敏感性,强烈建议使用
auth=gssapi
、scheme=ldaps
或start_tls=yes
运行。未能使用上述设置之一将导致帐户凭据以及LAPS密码以明文形式发送。
在具有较旧OpenLDAP安装(如MacOS)的主机上运行时,某些场景可能无法正常工作。建议安装最新版本的OpenLDAP并针对其构建python-ldap,有关更多信息,请参见https://keathmilligan.net/python-ldap-and-macos。
示例
# This isn't mandatory but it is a way to call kinit from within Ansible before calling the lookup
- name: call kinit to retrieve Kerberos token
expect:
command: kinit [email protected]
responses:
(?i)password: SecretPass1
no_log: true
- name: Get the LAPS password using Kerberos auth, relies on kinit already being called
set_fact:
ansible_password: "{{ lookup('community.windows.laps_password', 'SERVER', domain='dc01.ansible.com') }}"
- name: Specific the domain host using an explicit LDAP URI
set_fact:
ansible_password: "{{ lookup('community.windows.laps_password', 'SERVER', domain='ldap://ansible.org.cn:389') }}"
- name: Use Simple auth over LDAPS
set_fact:
ansible_password: "{{ lookup('community.windows.laps_password', 'server',
domain='dc01.ansible.com',
auth='simple',
scheme='ldaps',
username='[email protected]',
password='SuperSecret123') }}"
- name: Use Simple auth with LDAP and StartTLS
set_fact:
ansible_password: "{{ lookup('community.windows.laps_password', 'app01',
domain='dc01.ansible.com',
auth='simple',
start_tls=True,
username='[email protected]',
password='SuperSecret123') }}"
- name: Narrow down the search base to a an OU
set_fact:
ansible_password: "{{ lookup('community.windows.laps_password', 'sql10',
domain='dc01.ansible.com',
search_base='OU=Databases,DC=ansible,DC=com') }}"
- name: Set certificate file to use when validating the TLS certificate
set_fact:
ansible_password: "{{ lookup('community.windows.laps_password', 'windows-pc',
domain='dc01.ansible.com',
start_tls=True,
ca_cert='/usr/local/share/certs/ad.pem') }}"
返回值
键 |
描述 |
---|---|
请求的主机的LAPS密码。 返回:成功 |