ansible.builtin.zabbix_map (v2.8.13) — module

Create/update/delete Zabbix maps

| "added in version" 2.8 of ansible.builtin"

Authors: Antony Alekseyev (@Akint)

preview | supported by community

Install Ansible via pip

Install with pip install ansible==2.8.13

Description

This module allows you to create, modify and delete Zabbix map entries, using Graphviz binaries and text description written in DOT language. Nodes of the graph will become map elements and edges will become links between map elements. See U(https://en.wikipedia.org/wiki/DOT_(graph_description_language)) and U(https://www.graphviz.org/) for details. Inspired by U(http://blog.zabbix.com/maps-for-the-lazy/).

The following extra node attributes are supported: C(zbx_host) contains name of the host in Zabbix. Use this if desired type of map element is C(host). C(zbx_group) contains name of the host group in Zabbix. Use this if desired type of map element is C(host group). C(zbx_map) contains name of the map in Zabbix. Use this if desired type of map element is C(map). C(zbx_label) contains label of map element. C(zbx_image) contains name of the image used to display the element in default state. C(zbx_image_disabled) contains name of the image used to display disabled map element. C(zbx_image_maintenance) contains name of the image used to display map element in maintenance. C(zbx_image_problem) contains name of the image used to display map element with problems. C(zbx_url) contains map element URL in C(name:url) format. More than one url could be specified by adding some prefix (e.g., C(zbx_url1), C(zbx_url2)).

The following extra link attributes are supported: C(zbx_draw_style) contains link line draw style. Possible values: C(line), C(bold), C(dotted), C(dashed). C(zbx_trigger) contains name of the trigger used as a link indicator in C(host_name:trigger_name) format. More than one trigger could be specified by adding some prefix (e.g., C(zbx_trigger1), C(zbx_trigger2)). C(zbx_trigger_color) contains indicator color specified either as CSS3 name or as a hexadecimal code starting with C(#). C(zbx_trigger_draw_style) contains indicator draw style. Possible values are the same as for C(zbx_draw_style).


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
###
### Example inventory:
# [web]
# web[01:03].example.com ansible_host=127.0.0.1
# [db]
# db.example.com  ansible_host=127.0.0.1
# [backup]
# backup.example.com   ansible_host=127.0.0.1
###
### Each inventory host presents in Zabbix with same name.
###
### Contents of 'map.j2':
# digraph G {
#     graph [layout=dot splines=false overlap=scale]
#     INTERNET [zbx_url="Google:https://google.com" zbx_image="Cloud_(96)"]
# {% for web_host in groups.web %}
#     {% set web_loop = loop %}
#     web{{ '%03d' % web_loop.index }} [zbx_host="{{ web_host }}"]
#     INTERNET -> web{{ '%03d' % web_loop.index }} [zbx_trigger="{{ web_host }}:Zabbix agent on {HOST.NAME} is unreachable for 5 minutes"]
#     {% for db_host in groups.db %}
#       {% set db_loop = loop %}
#     web{{ '%03d' % web_loop.index }} -> db{{ '%03d' % db_loop.index }}
#     {% endfor %}
# {% endfor %}
#     { rank=same
# {% for db_host in groups.db %}
#     {% set db_loop = loop %}
#     db{{ '%03d' % db_loop.index }} [zbx_host="{{ db_host }}"]
#     {% for backup_host in groups.backup %}
#         {% set backup_loop = loop %}
#         db{{ '%03d' % db_loop.index }} -> backup{{ '%03d' % backup_loop.index }} [color="blue"]
#     {% endfor %}
# {% endfor %}
# {% for backup_host in groups.backup %}
#     {% set backup_loop = loop %}
#         backup{{ '%03d' % backup_loop.index }} [zbx_host="{{ backup_host }}"]
# {% endfor %}
#     }
# }
###
### Create Zabbix map "Demo Map" made of template 'map.j2'
- name: Create Zabbix map
  zabbix_map:
    server_url: http://zabbix.example.com
    login_user: username
    login_password: password
    name: Demo map
    state: present
    data: "{{ lookup('template', 'map.j2') }}"
    default_image: Server_(64)
    expand_problem: no
    highlight: no
    label_type: label
  delegate_to: localhost
  run_once: yes

Inputs

    
data:
    aliases:
    - dot_data
    description:
    - Graph written in DOT language.
    required: false

name:
    aliases:
    - map_name
    description:
    - Name of the map.
    required: true

state:
    choices:
    - present
    - absent
    default: present
    description:
    - State of the map.
    - On C(present), it will create if map does not exist or update the map if the associated
      data is different.
    - On C(absent) will remove the map if it exists.
    required: false

width:
    default: 800
    description:
    - Width of the map.
    required: false

height:
    default: 600
    description:
    - Height of the map.
    required: false

margin:
    default: 40
    description:
    - Size of white space between map's borders and its elements.
    required: false

highlight:
    default: true
    description:
    - Whether icon highlighting is enabled.
    required: false
    type: bool

label_type:
    choices:
    - label
    - ip
    - name
    - status
    - nothing
    - custom
    default: name
    description:
    - Map element label type.
    required: false

default_image:
    aliases:
    - image
    description:
    - Name of the Zabbix image used to display the element if this element doesn't have
      the C(zbx_image) attribute defined.
    required: false

expand_problem:
    default: true
    description:
    - Whether the the problem trigger will be displayed for elements with a single problem.
    required: false
    type: bool

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

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