community.zabbix.zabbix_service (2.3.1) — module

Create/update/delete Zabbix service

Authors: Emmanuel Riviere (@emriver), Evgeny Yurchenko (@BGmot)

Install collection

Install with ansible-galaxy collection install community.zabbix:==2.3.1


Add to requirements.yml

  collections:
    - name: community.zabbix
      version: 2.3.1

Description

Create/update/delete Zabbix service.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
---
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# 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
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# Creates a new Zabbix service
- name: Create Zabbix service monitoring Apache2 in DCs in Toronto area
  # set task level variables
  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_service:
    name: "apache2 service Toronto"
    description: Apache2 services in Toronto area
    sortorder: 0
    propagation_rule: increase
    propagation_value: warning
    weight: 1
    state: present
    tags:
      - tag: zabbix_service
        value: apache2
      - tag: area
        value: Toronto
    problem_tags:
      - tag: service_name
        value: httpd
      - tag: area
        operator: like
        value: toronto
    status_rules:
      - type: at_least_n_child_services_have_status_or_above
        limit_value: 4242
        limit_status: ok
        new_status: average
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Create Zabbix service monitoring all Apache2 services
  # 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_service:
    name: apache2 service
    description: Apache2 services
    tags:
      - tag: zabbix_service
        value: apache2
      - tag: area
        value: global
    children:
      - "apache2 service Toronto"

Inputs

    
name:
    description:
    - Name of Zabbix service
    required: true
    type: str

tags:
    description:
    - Service tags to be created for the service.
    elements: dict
    required: false
    suboptions:
      tag:
        description:
        - Service tag name.
        required: true
        type: str
      value:
        description:
        - Service tag value.
        required: false
        type: str
    type: list

state:
    choices:
    - present
    - absent
    default: present
    description:
    - 'State: present - create/update service; absent - delete service.'
    required: false
    type: str

weight:
    default: '0'
    description:
    - Service weight.
    required: false
    type: str

parents:
    description:
    - Parent services to be linked to the service.
    elements: str
    required: false
    type: list

children:
    description:
    - Child services to be linked to the service.
    elements: str
    required: false
    type: list

algorithm:
    choices:
    - status_to_ok
    - most_crit_if_all_children
    - most_crit_of_child_serv
    default: status_to_ok
    description:
    - Status calculation rule. Only applicable if child services exists.
    - ' - C(status_to_ok), set status to OK with'
    - ' - C(most_crit_if_all_children), most critical if all children have problems'
    - ' - C(most_crit_of_child_serv), most critical of child services with'
    required: false
    type: str

sortorder:
    description:
    - Position of the service used for sorting.
    required: true
    type: str

description:
    description:
    - Description of the service.
    required: false
    type: str

problem_tags:
    description:
    - Problem tags to be created for the service.
    elements: dict
    required: false
    suboptions:
      operator:
        choices:
        - equals
        - like
        default: equals
        description:
        - Mapping condition operator.
        - C(equals)
        - C(like)
        required: false
        type: str
      tag:
        description:
        - Problem tag name.
        required: true
        type: str
      value:
        default: ''
        description:
        - Problem tag value.
        required: false
        type: str
    type: list

status_rules:
    description:
    - Status rules for the service.
    elements: dict
    required: false
    suboptions:
      limit_status:
        description:
        - Limit status.
        - C(ok) OK
        - C(not_classified) Not classified
        - C(information) Information
        - C(warning) Warning
        - C(average) Average
        - C(high) High
        - C(disaster) Disaster
        required: true
        type: str
      limit_value:
        description:
        - 'Limit value: N, N% or W'
        - 'Possible values: 1-100000 for N and W, 1-100 for N%'
        required: true
        type: int
      new_status:
        description:
        - New status value.
        - C(not_classified) Not classified
        - C(information) Information
        - C(warning) Warning
        - C(average) Average
        - C(high) High
        - C(disaster) Disaster
        required: true
        type: str
      type:
        description:
        - Condition for setting (New status) status.
        - C(at_least_n_child_services_have_status_or_above) if at least (N) child services
          have (Status) status or above
        - C(at_least_npct_child_services_have_status_or_above) if at least (N%) of child
          services have (Status) status or above
        - C(less_than_n_child_services_have_status_or_below) if less than (N) child services
          have (Status) status or below
        - C(less_than_npct_child_services_have_status_or_below) if less than (N%) of child
          services have (Status) status or below
        - C(weight_child_services_with_status_or_above_at_least_w) if weight of child
          services with (Status) status or above is at least (W)
        - C(weight_child_services_with_status_or_above_at_least_npct) if weight of child
          services with (Status) status or above is at least (N%)
        - C(weight_child_services_with_status_or_below_less_w) if weight of child services
          with (Status) status or below is less than (W)
        - C(weight_child_services_with_status_or_below_less_npct) if weight of child services
          with (Status) status or below is less than (N%)
        required: true
        type: str
    type: list

http_login_user:
    description:
    - Basic Auth login
    required: false
    type: str

propagation_rule:
    default: as_is
    description:
    - Status propagation value. Must be set together with propagation_rule.
    - C(as_is) propagate service status as is - without any changes
    - C(increase) increase the propagated status by a given propagation_value (by 1 to
      5 severities)
    - C(decrease) decrease the propagated status by a given propagation_value (by 1 to
      5 severities)
    - C(ignore) ignore this service - the status is not propagated to the parent service
      at all
    - C(fixed) set fixed service status using a given propagation_value
    - Required with C(propagation_value)
    required: false
    type: str

propagation_value:
    description:
    - Status propagation value. Must be set together with propagation_rule.
    - 'Possible values when I(propagation_rule=as_is or ignore):'
    - ' - C(not_classified)'
    - 'Possible values when I(propagation_rule=increase or decrease):'
    - ' - C(information)'
    - ' - C(warning)'
    - ' - C(average)'
    - ' - C(high)'
    - ' - C(disaster)'
    - 'Possible values when I(propagation_rule=fixed):'
    - ' - C(ok)'
    - ' - C(not_classified)'
    - ' - C(information)'
    - ' - C(warning)'
    - ' - C(average)'
    - ' - C(high)'
    - ' - C(disaster)'
    - Required with C(propagation_rule)
    required: false
    type: str

http_login_password:
    description:
    - Basic Auth password
    required: false
    type: str