GithubHelp home page GithubHelp logo

ansible-zabbix-api's Introduction

ansible Zabbix-API

This module will let you synchronize ansible hosts state with Zabbix. It means that it sets hosts via Zabbix API based on ansible variables:

  • groups the host should belong to;
  • templates the host should be linked to;
  • macros the host should contain.

Groups and Tempalates provided by ansible variables MUST be already present in Zabbix.

Web access from nodes managed by ansible to the Zabbix API should be allowed (firewall).

Make sure API user for provided credentials has enough permissions for host groups in Zabbix.

You can treat ansible inventory as an authoritative source of host information and sync it to Zabbix.

Tested on Zabbix 3.0.1.

Requirements

None.

Role Variables

Available variables are listed below, along with default values (see defaults/main.yml):

  • zabbix_default_group - Default Zabbix group all hosts should belong to. Only hosts from this group are considered during synchronization (default "ansible").
  • zabbix_templates - Comma separated list of Zabbix templates the host should be linked to.
  • zabbix_groups - Comma separated list of Zabbix groups the host should belong to.
  • zabbix_macros - Comma separated list of Zabbix macros which should be added to the host. Odd items are macro keys, even items are macro values, eg.: '{$MACRO1},value1,{$MACRO2},value2'.
  • zabbix_url - Zabbix API URL.
  • zabbix_user and zabbix_password - Zabbix API credentials.
  • zabbix_basic_auth_user and zabbix_basic_auth_password - Optional basic AUTH credentials if required.

Example

Variables

zabbix_url: 'http://zabbixhost.com/api_jsonrpc.php'
zabbix_user: 'ansible'
zabbix_password: 'secretpassword'
  
zabbix_templates: 'mysql,nginx,php-fpm,LXC Containers,Web Test'
zabbix_groups: 'LXC Containers,Webservers'
zabbix_macros: '{$PAGE_STRING},Welcome on main page,{$SNMP_COMMUNITY},public'

Playbook

- name: zabbix API
  hosts: all
  roles:
    - role: r0bj.zabbix-api

License

MIT

Author Information

This role was created in 2014 by Robert Jerzak.

ansible-zabbix-api's People

Contributors

dj-wasabi avatar r0bj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ansible-zabbix-api's Issues

Add TLS support

Found lack of TLS support in zabbix-api library.
Here is my diff to add it.

Usage example:
local_action:
module: zabbix_api
action: sync_host
hostname: "{{ inventory_hostname }}"
...
tls_connect: 3
tls_accept: 3
tls_psk_identity: "PSK 001"
tls_psk: "af8ced32dfe8714e548694e2d29e1a14ba6fa13f216cb35c19d0feb1084b0429"

zabbix_api.diff.txt

Make the extra template removal configurable

We have different playbooks that match up with different templates in Zabbix. It would be really cool if it could be configured to not remove templates for servers that are already existing, just like a configurable option that is defaulting to true or such. We sometimes use a single server for multiple functions depending on the environment and don't want to have to choose which one we group it up for using your awesome module.

Error when updating host, who already have macro

TASK: [add-host-to-zabbix | sync host with zabbix] ****************************
failed: [XXX.XXX.XXX.XXX] => {"failed": true, "parsed": false}
BECOME-SUCCESS-gwzstkkqbghamsvvynimornizrtlmckp
Traceback (most recent call last):
File "/home/user/.ansible/tmp/ansible-tmp-1434540025.65-71459539167281/zabbix-api", line 2217, in
main()
File "/home/user/.ansible/tmp/ansible-tmp-1434540025.65-71459539167281/zabbix-api", line 581, in main
templates,
File "/home/user/.ansible/tmp/ansible-tmp-1434540025.65-71459539167281/zabbix-api", line 392, in sync_host
self.__compare_macros(hostdump, macros_list)
File "/home/user/.ansible/tmp/ansible-tmp-1434540025.65-71459539167281/zabbix-api", line 365, in __compare_macros
if dump_macro['macro'] + dump_macro['value'] not in keyvalues:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.