zabbix_host – Create/update/delete Zabbix hosts

New in version 2.0.

Synopsis

  • This module allows you to create, modify and delete Zabbix host entries and associated group and template data.

Requirements

The below requirements are needed on the host that executes this module.

  • python >= 2.6

  • zabbix-api >= 0.5.3

Parameters

Parameter Choices/Defaults Comments
ca_cert
-
added in 2.5
Required certificate issuer.
Works only with >= Zabbix 3.0

aliases: tls_issuer
description
-
added in 2.5
Description of the host in Zabbix.
force
boolean
added in 2.0
    Choices:
  • no
  • yes ←
Overwrite the host configuration, even if already present.
host_groups
-
List of host groups the host is part of.
host_name
- / required
Name of the host in Zabbix.
host_name is the unique identifier used and cannot be updated using this module.
http_login_password
string
added in 2.1
Basic Auth password
http_login_user
string / required
added in 2.1
Basic Auth login
interfaces
-
Default:
[]
List of interfaces to be created for the host (see example below).
Available keys are: dns, ip, main, port, type, useip, and bulk.
Please review the interface documentation for more information on the supported properties
https://www.zabbix.com/documentation/2.0/manual/appendix/api/hostinterface/definitions#host_interface
If an interface definition is incomplete, this module will attempt to fill in sensible values.
type can also be agent, snmp, ipmi, or jmx instead of its numerical value.
inventory_mode
-
added in 2.1
    Choices:
  • automatic
  • manual
  • disabled
Configure the inventory mode.
inventory_zabbix
-
added in 2.5
Add Facts for a zabbix inventory (e.g. Tag) (see example below).
Please review the interface documentation for more information on the supported properties
https://www.zabbix.com/documentation/3.2/manual/api/reference/host/object#host_inventory
ipmi_authtype
-
added in 2.5
IPMI authentication algorithm.
Please review the Host object documentation for more information on the supported properties
https://www.zabbix.com/documentation/3.4/manual/api/reference/host/object
Possible values are, 0 (none), 1 (MD2), 2 (MD5), 4 (straight), 5 (OEM), 6 (RMCP+), with -1 being the API default.
Please note that the Zabbix API will treat absent settings as default when updating any of the ipmi_-options; this means that if you attempt to set any of the four options individually, the rest will be reset to default values.
ipmi_password
-
added in 2.5
IPMI password.
also see the last note in the ipmi_authtype documentation
ipmi_privilege
-
added in 2.5
IPMI privilege level.
Please review the Host object documentation for more information on the supported properties
https://www.zabbix.com/documentation/3.4/manual/api/reference/host/object
Possible values are 1 (callback), 2 (user), 3 (operator), 4 (admin), 5 (OEM), with 2 being the API default.
also see the last note in the ipmi_authtype documentation
ipmi_username
-
added in 2.5
IPMI username.
also see the last note in the ipmi_authtype documentation
link_templates
-
List of templates linked to the host.
login_password
string / required
Zabbix user password.
login_user
string / required
Zabbix user name.
proxy
-
The name of the Zabbix proxy to be used.
server_url
string / required
URL of Zabbix server, with protocol (http or https). url is an alias for server_url.

aliases: url
state
-
    Choices:
  • present ←
  • absent
State of the host.
On present, it will create if host does not exist or update the host if the associated data is different.
On absent will remove a host if it exists.
status
-
    Choices:
  • enabled ←
  • disabled
Monitoring status of the host.
timeout
integer
Default:
10
The timeout of API request (seconds).
tls_accept
-
added in 2.5
Default:
1
Specifies what types of connections are allowed for incoming connections.
The tls_accept parameter accepts values of 1 to 7
Possible values, 1 (no encryption), 2 (PSK), 4 (certificate).
Values can be combined.
Works only with >= Zabbix 3.0
tls_connect
-
added in 2.5
Default:
1
Specifies what encryption to use for outgoing connections.
Possible values, 1 (no encryption), 2 (PSK), 4 (certificate).
Works only with >= Zabbix 3.0
tls_psk
-
added in 2.5
PSK value is a hard to guess string of hexadecimal digits.
The preshared key, at least 32 hex digits. Required if either tls_connect or tls_accept has PSK enabled.
Works only with >= Zabbix 3.0
tls_psk_identity
-
added in 2.5
It is a unique name by which this specific PSK is referred to by Zabbix components
Do not put sensitive information in the PSK identity string, it is transmitted over the network unencrypted.
Works only with >= Zabbix 3.0
tls_subject
-
added in 2.5
Required certificate subject.
Works only with >= Zabbix 3.0
validate_certs
boolean
added in 2.5
    Choices:
  • no
  • yes ←
If set to False, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates.
visible_name
-
added in 2.3
Visible name of the host in Zabbix.

Examples

- name: Create a new host or update an existing host's info
  local_action:
    module: zabbix_host
    server_url: http://monitor.example.com
    login_user: username
    login_password: password
    host_name: ExampleHost
    visible_name: ExampleName
    description: My ExampleHost Description
    host_groups:
      - Example group1
      - Example group2
    link_templates:
      - Example template1
      - Example template2
    status: enabled
    state: present
    inventory_mode: manual
    inventory_zabbix:
      tag: "{{ your_tag }}"
      alias: "{{ your_alias }}"
      notes: "Special Informations: {{ your_informations | default('None') }}"
      location: "{{ your_location }}"
      site_rack: "{{ your_site_rack }}"
      os: "{{ your_os }}"
      hardware: "{{ your_hardware }}"
    ipmi_authtype: 2
    ipmi_privilege: 4
    ipmi_username: username
    ipmi_password: password
    interfaces:
      - type: 1
        main: 1
        useip: 1
        ip: 10.xx.xx.xx
        dns: ""
        port: 10050
      - type: 4
        main: 1
        useip: 1
        ip: 10.xx.xx.xx
        dns: ""
        port: 12345
    proxy: a.zabbix.proxy
- name: Update an existing host's TLS settings
  local_action:
    module: zabbix_host
    server_url: http://monitor.example.com
    login_user: username
    login_password: password
    host_name: ExampleHost
    visible_name: ExampleName
    host_groups:
      - Example group1
    tls_psk_identity: test
    tls_connect: 2
    tls_psk: 123456789abcdef123456789abcdef12

Status

Authors

  • Cove (@cove)

  • Tony Minfei Ding (!UNKNOWN)

  • Harrison Gu (@harrisongu)

  • Werner Dijkerman (@dj-wasabi)

  • Eike Frost (@eikef)

Hint

If you notice any issues in this documentation you can edit this document to improve it.