Skip to content

flashick/ansible-zabbix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

ansible-zabbix

[Ansible][src_ansible] wrapper for py-zabbix

This module uses the Zabbix API to make requests to zabbix server.

Requirements

Python module py-zabbix, install with pip install py-zabbix [src_ansible]: https://github.com/ansible/ansible

Notes

Examples

Get groupid by name

- name: hostgroup name to groupid
  zabbix:
    server: 'https://zabbix-server.example.com'
    login: 'api_user'
    password: 'api_user_password'
    action: 'get'
    object: 'hostgroup'
    params:
      filter:
        name:
         - "My favorite host group"
- set_fact:
    groupid: "{{ response.result[0].groupid }}"

Create new host in group 'My favorite host group'

- name: add new hosts
  zabbix:
    server: 'https://zabbix-server.example.com'
    login: 'api_user'
    password: 'api_user_password'
    action: 'create'
    object: 'host'
    params:
      host: 'Sample host'
      groups:
        - groupid:  "{{ groupid }}"
      templates:
        - templateid: 5
      interfaces:
        - type: 1
          main: 1
          useip: 1
          ip: "127.0.0.1"
          port: 10050
          dns: ""

Get all hosts in group 'My favorite host group'

- name: get existing hosts
  zabbix:
    server: 'https://zabbix-server.example.com'
    login: 'api_user'
    password: 'api_user_password'
    action: 'get'
    object: 'host'
    params:
      groupids: "{{ groupid }}"
- set_fact:
    host_list: "{{ response.result }}"

Delete all hosts in group 'My favorite host group'

- name: delete hosts
  zabbix:
    server: 'https://zabbix-server.example.com'
    login: 'api_user'
    password: 'api_user_password'
    action: 'delete'
    object: 'host'
    params:
      - "{{ item.hostid }}"
  with_items: "{{ host_list }}"

About

ansible wrapper for py-zabbix

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages