zabbix.zabbix.zabbix_hostgroup (1.3.6) — module

Module for creating and deleting host groups

Authors: Zabbix Ltd (@zabbix)

Install collection

Install with ansible-galaxy collection install zabbix.zabbix:==1.3.6


Add to requirements.yml

  collections:
    - name: zabbix.zabbix
      version: 1.3.6

Description

Creation of new host groups.

The module will only create the missing host groups if some of the listed are already created in Zabbix.

Removing host groups from Zabbix.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# To create host groups, you can use:
- name: Create host groups
  zabbix.zabbix.zabbix_hostgroup:
    state: present
    hostgroups:
      - G1
      - G2
  vars:
    ansible_network_os: zabbix.zabbix.zabbix
    ansible_connection: httpapi
    ansible_user: Admin
    ansible_httpapi_pass: zabbix
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# To delete two host groups - G1 and G2
- name: Delete host groups by name
  zabbix.zabbix.zabbix_hostgroup:
    state: absent
    hostgroups:
      - G1
      - G2
  vars:
    ansible_network_os: zabbix.zabbix.zabbix
    ansible_connection: httpapi
    ansible_user: Admin
    ansible_httpapi_pass: zabbix
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
# You can configure Zabbix API connection settings with the following parameters:
- name: Create host groups
  zabbix.zabbix.zabbix_hostgroup:
    state: present
    hostgroups:
      - G1
  vars:
    # Connection parameters
    ansible_host: zabbix-api.com                # Specifying Zabbix API address. You can also use 'delegate_to'.
    ansible_connection: httpapi                 # Specifying to use HTTP API plugin.
    ansible_network_os: zabbix.zabbix.zabbix    # Specifying which HTTP API plugin to use.
    ansible_httpapi_port: 80                    # Specifying the port for connecting to Zabbix API.
    ansible_httpapi_use_ssl: false              # Specifying the type of connection. True for https, False for http (by default).
    ansible_httpapi_validate_certs: false       # Specifying certificate validation.
    # User parameters for connecting to Zabbix API
    ansible_user: Admin                         # Username to connect to Zabbix API.
    ansible_httpapi_pass: zabbix                # Password to connect to Zabbix API.
    # Token for connecting to Zabbix API
    zabbix_api_token: your_secret_token         # Specify your token to connect to Zabbix API.
    # Path to connect to Zabbix API
    zabbix_api_url: '/zabbix'                   # The field is empty by default. You can specify your connection path (e.g., '/zabbix').
    # User parameters for basic HTTP authorization
    # These options only affect the basic HTTP authorization configured on the web server.
    http_login: my_http_login                   # Username for connecting to API in case of additional basic HTTP authorization.
    http_password: my_http_password             # Password for connecting to API in case of additional basic HTTP authorization.

Inputs

    
state:
    choices:
    - present
    - absent
    default: present
    description: Action with host groups. Present to create, absent to remove.
    required: false
    type: str

hostgroups:
    aliases:
    - host_group
    - host_groups
    - name
    description: List of host groups to create/remove.
    elements: str
    required: true
    type: list