community.general.ldap_attrs 模块 – 添加或删除多个 LDAP 属性值
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您使用的是 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.general
。您需要其他要求才能使用此模块,请参阅 要求 了解详细信息。
要在 playbook 中使用它,请指定:community.general.ldap_attrs
。
community.general 0.2.0 中的新增功能
概要
添加或删除多个 LDAP 属性值。
要求
执行此模块的主机需要以下要求。
python-ldap
参数
参数 |
注释 |
---|---|
要添加或删除的属性和值。 每个属性值可以是单值属性的字符串,也可以是多值属性的字符串列表。 如果您在 YAML 中为此选项指定值,请注意,您可以使用 YAML 块修饰符来提高长字符串值的可读性,如本模块的示例所示。 请注意,当使用 YAML/ansible-core 解释为其他类型的值时,例如 |
|
要绑定的 DN。如果省略此项,我们将尝试使用 EXTERNAL 机制进行 SASL 绑定作为默认值。 如果此项为空,我们将使用匿名绑定。 |
|
要与 默认值: |
|
设置包含 CA 证书的 PEM 文件的路径。 |
|
用于 SSL 客户端身份验证的 PEM 格式证书链文件。 如果定义了 |
|
包含用于 SSL 客户端身份验证的私钥的 PEM 格式文件。 如果定义了 |
|
要添加或删除的条目的 DN。 |
|
如果为 选择
|
|
设置引荐跟踪行为。
选择
|
|
用于 SASL 身份验证的类。 选择
|
|
默认值允许底层 LDAP 客户端库在其默认位置查找 UNIX 域套接字。 请注意,当使用多个 URI 时,您无法确定客户端连接到哪个 URI。 对于包含额外字段的 URI,特别是使用逗号时,行为是未定义的。 默认值: |
|
如果为 true,我们将使用 START_TLS LDAP 扩展。 选择
|
|
属性值的状态。如果为 选择
|
|
如果设置为 这仅应在使用自签名证书的站点上使用。 选择
|
|
设置如何处理 Xordered DN 的行为。
选择
|
属性
属性 |
支持 |
描述 |
---|---|---|
支持: 完全 |
可以在 |
|
支持: 完全 在 community.general 8.5.0 中添加 |
当处于 diff 模式时,将返回已更改(或可能需要在 |
备注
注意
这仅处理现有条目上的属性。要添加或删除整个条目,请参阅 community.general.ldap_entry。
默认的身份验证设置将尝试使用 SASL EXTERNAL 绑定通过 UNIX 域套接字。例如,这与默认的 Ubuntu 安装配合使用效果很好,其中包括允许 root 修改服务器配置的 cn=peercred,cn=external,cn=auth ACL 规则。如果您需要使用简单绑定来访问服务器,请在
bind_dn
和bind_pw
中传递凭据。对于
state=present
和state=absent
,所有值比较都在服务器上执行,以获得最大精度。对于state=exact
,必须在 Python 中比较值,这显然会忽略 LDAP 匹配规则。这在大多数情况下应该可以正常工作,但理论上可能会在目标值和实际值在语义上相同但在词汇上不同时看到虚假的更改。
示例
- name: Configure directory number 1 for example.com
community.general.ldap_attrs:
dn: olcDatabase={1}hdb,cn=config
attributes:
olcSuffix: dc=example,dc=com
state: exact
# The complex argument format is required here to pass a list of ACL strings.
- name: Set up the ACL
community.general.ldap_attrs:
dn: olcDatabase={1}hdb,cn=config
attributes:
olcAccess:
- >-
{0}to attrs=userPassword,shadowLastChange
by self write
by anonymous auth
by dn="cn=admin,dc=example,dc=com" write
by * none'
- >-
{1}to dn.base="dc=example,dc=com"
by dn="cn=admin,dc=example,dc=com" write
by * read
state: exact
# An alternative approach with automatic X-ORDERED numbering
- name: Set up the ACL
community.general.ldap_attrs:
dn: olcDatabase={1}hdb,cn=config
attributes:
olcAccess:
- >-
to attrs=userPassword,shadowLastChange
by self write
by anonymous auth
by dn="cn=admin,dc=example,dc=com" write
by * none'
- >-
to dn.base="dc=example,dc=com"
by dn="cn=admin,dc=example,dc=com" write
by * read
ordered: true
state: exact
- name: Declare some indexes
community.general.ldap_attrs:
dn: olcDatabase={1}hdb,cn=config
attributes:
olcDbIndex:
- objectClass eq
- uid eq
- name: Set up a root user, which we can use later to bootstrap the directory
community.general.ldap_attrs:
dn: olcDatabase={1}hdb,cn=config
attributes:
olcRootDN: cn=root,dc=example,dc=com
olcRootPW: "{SSHA}tabyipcHzhwESzRaGA7oQ/SDoBZQOGND"
state: exact
- name: Remove an attribute with a specific value
community.general.ldap_attrs:
dn: uid=jdoe,ou=people,dc=example,dc=com
attributes:
description: "An example user account"
state: absent
server_uri: ldap://127.0.0.1/
bind_dn: cn=admin,dc=example,dc=com
bind_pw: password
- name: Remove specified attribute(s) from an entry
community.general.ldap_attrs:
dn: uid=jdoe,ou=people,dc=example,dc=com
attributes:
description: []
state: exact
server_uri: ldap://127.0.0.1/
bind_dn: cn=admin,dc=example,dc=com
bind_pw: password
返回值
常见返回值在此处记录 此处,以下是此模块特有的字段
键 |
描述 |
---|---|
修改的参数列表 返回: 成功 示例: |