community.zabbix.zabbix_user 模块 – 创建/更新/删除 Zabbix 用户
注意
此模块是 community.zabbix 集合(版本 3.2.0)的一部分。
如果您使用的是 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用:ansible-galaxy collection install community.zabbix
。您需要进一步的要求才能使用此模块,请参阅 要求 了解详细信息。
要在 playbook 中使用它,请指定:community.zabbix.zabbix_user
。
概要
此模块允许您创建、修改和删除 Zabbix 用户。
要求
执行此模块的主机需要满足以下要求。
python >= 3.9
参数
参数 |
注释 |
---|---|
用户登录后要重定向到的页面 URL。 |
|
是否启用自动登录。 如果启用自动登录,则无法启用自动注销。 选项
|
|
用户会话生命周期(以秒为单位)。如果设置为 0,则会话将永不过期。 如果启用自动注销,则无法启用自动登录。 |
|
覆盖用户密码时用户的当前密码。 当覆盖已登录用户的密码时是必需的。 https://www.zabbix.com/documentation/6.4/en/manual/api/reference/user/update |
|
基本身份验证密码 |
|
基本身份验证登录名 |
|
用户语言的语言代码。 选项
|
|
用户名。 |
|
覆盖用户的密码。 如果不将此值设置为 yes,则密码不会在后续运行中更新。 选项
|
|
用户密码。 除非所有 usrgrps 都设置为使用 LDAP 作为前端访问,否则是必需的。 |
|
自动刷新周期(以秒为单位)。 |
|
用户的角色。 创建新用户时,默认值为 默认值将在版本 2.0.0 中删除。 |
|
每页显示的对象行数。 |
|
用户的状态。 在 在 选项
|
|
用户的姓氏。 |
|
用户的主题。 选项
|
|
用户的时区。 有关支持的时区的完整列表,请参阅 https://php.net/manual/en/timezones.php |
|
设置用户的媒体。 如果未设置,则不对媒体进行任何更改。 |
|
是否启用媒体。 选项
|
|
要设置的媒体类型名称。 默认: |
|
通知可以作为时间段或用户宏发送的时间,以分号分隔。 请查看文档以获取有关支持的时间段的更多信息。 https://www.zabbix.com/documentation/current/en/manual/appendix/time_period 默认: |
|
收件人的地址、用户名或其他标识符。 如果 |
|
要发送通知的触发器严重性。 默认: |
|
严重性 average 启用/禁用。 选项
|
|
严重性 disaster 启用/禁用。 选项
|
|
严重性 high 启用/禁用。 选项
|
|
严重性 information 启用/禁用。 选项
|
|
严重性 not_classified 启用/禁用。 选项
|
|
启用/禁用严重性警告。 选项
|
|
用户名。 用户名是使用的唯一标识符,不能使用此模块更新。 |
|
要将用户添加到的用户组。 当state=present时是必需的。 |
示例
# If you want to use Username and Password to be authenticated by Zabbix Server
- name: Set credentials to access Zabbix Server API
ansible.builtin.set_fact:
ansible_user: Admin
ansible_httpapi_pass: zabbix
# If you want to use API token to be authenticated by Zabbix Server
# https://www.zabbix.com/documentation/current/en/manual/web_interface/frontend_sections/administration/general#api-tokens
- name: Set API token
ansible.builtin.set_fact:
ansible_zabbix_auth_key: 8ec0d52432c15c91fcafe9888500cf9a607f44091ab554dbee860f6b44fac895
- name: create a new zabbix user.
# set task level variables as we change ansible_connection plugin here
vars:
ansible_network_os: community.zabbix.zabbix
ansible_connection: httpapi
ansible_httpapi_port: 443
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
ansible_zabbix_url_path: "zabbixeu" # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu
ansible_host: zabbix-example-fqdn.org
community.zabbix.zabbix_user:
username: example
name: user name
surname: user surname
usrgrps:
- Guests
- Disabled
passwd: password
lang: en_GB
theme: blue-theme
autologin: no
autologout: "0"
refresh: "30"
rows_per_page: "200"
after_login_url: ""
user_medias:
- mediatype: Email
sendto:
- [email protected]
- [email protected]
period: 1-7,00:00-24:00
severity:
not_classified: no
information: yes
warning: yes
average: yes
high: yes
disaster: yes
active: no
state: present
- name: delete existing zabbix user.
# set task level variables as we change ansible_connection plugin here
vars:
ansible_network_os: community.zabbix.zabbix
ansible_connection: httpapi
ansible_httpapi_port: 443
ansible_httpapi_use_ssl: true
ansible_httpapi_validate_certs: false
ansible_zabbix_url_path: "zabbixeu" # If Zabbix WebUI runs on non-default (zabbix) path ,e.g. http://<FQDN>/zabbixeu
ansible_host: zabbix-example-fqdn.org
community.zabbix.zabbix_user:
username: example
state: absent
返回值
通用返回值记录在此处,以下是此模块特有的字段
键 |
描述 |
---|---|
创建或更改的用户 ID 返回: 成功 示例: |