community.zabbix.zabbix_user_role 模块 – 添加或删除 Zabbix 角色

注意

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

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

要安装它,请使用:ansible-galaxy collection install community.zabbix。您需要其他要求才能使用此模块,有关详细信息,请参阅 要求

要在 playbook 中使用它,请指定:community.zabbix.zabbix_user_role

概要

  • 此模块添加或删除 Zabbix 角色

要求

在执行此模块的主机上需要以下要求。

  • python >= 3.9

参数

参数

注释

http_login_password

字符串

基本身份验证密码

http_login_user

字符串

基本身份验证登录名

name

字符串 / 必需

要处理的角色名称

rules

字典

state

字符串

用户角色的状态。

present 状态下,如果用户角色不存在,则会创建它;如果关联的数据不同,则会更新用户角色。

absent 状态下,如果用户角色存在,则会删除它。

选项

  • "present" ← (默认)

  • "absent"

type

字符串

用户类型。

选项

  • "User" ← (默认)

  • "Admin"

  • "Super Admin"

示例

# 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

# Create user role Operators with ui elements monitoring.hosts
# disabled and monitoring.maps enabled

- name: Create Zabbix user role
  # 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_role:
    state: present
    name: Operators
    type: User
    rules:
      ui.default_access: 0
      ui:
        - name: "monitoring.hosts"
          status: 0
        - name: "monitoring.maps"
          status: 1

返回值

公共返回值已在 此处 记录,以下是此模块特有的字段

描述

changed

布尔值

操作的结果

返回: 始终

示例: false

msg

字符串

操作的结果

返回: 始终

示例: "No action"

作者

  • Martin van Es (@mrvanes)