blob: f585bcbb2717c7b33b54d466849944bb0489fc85 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
---
# This is a test playbook to create one of each of the zabbix ansible modules.
# ensure that the zbxapi module is installed
# ansible-playbook test.yml
- name: Test zabbix ansible module
hosts: localhost
gather_facts: no
vars:
zbx_server: http://localhost/zabbix/api_jsonrpc.php
zbx_user: Admin
zbx_password: zabbix
pre_tasks:
- name: Create a template
zbx_template:
server: "{{ zbx_server }}"
user: "{{ zbx_user }}"
password: "{{ zbx_password }}"
name: 'test template'
register: template_output
- debug: var=template_output
- name: Create an item
zbx_item:
server: "{{ zbx_server }}"
user: "{{ zbx_user }}"
password: "{{ zbx_password }}"
name: 'test item'
key: 'kenny.item.1'
template_name: "{{ template_output.results[0].host }}"
register: item_output
- debug: var=item_output
- name: Create an trigger
zbx_trigger:
server: "{{ zbx_server }}"
user: "{{ zbx_user }}"
password: "{{ zbx_password }}"
expression: '{test template:kenny.item.1.last()}>2'
desc: 'Kenny desc'
register: trigger_output
- debug: var=trigger_output
- name: Create a hostgroup
zbx_hostgroup:
server: "{{ zbx_server }}"
user: "{{ zbx_user }}"
password: "{{ zbx_password }}"
name: 'kenny hostgroup'
register: hostgroup_output
- debug: var=hostgroup_output
- name: Create a host
zbx_host:
server: "{{ zbx_server }}"
user: "{{ zbx_user }}"
password: "{{ zbx_password }}"
name: 'kenny host'
hostgroups:
- 'kenny hostgroup'
register: host_output
- debug: var=host_output
- name: Create a usergroup
zbx_usergroup:
server: "{{ zbx_server }}"
user: "{{ zbx_user }}"
password: "{{ zbx_password }}"
name: kenny usergroup
rights:
- 'kenny hostgroup': rw
register: usergroup_output
- debug: var=usergroup_output
- name: Create a user
zbx_user:
server: "{{ zbx_server }}"
user: "{{ zbx_user }}"
password: "{{ zbx_password }}"
alias: kenny user
passwd: zabbix
usergroups:
- kenny usergroup
register: user_output
- debug: var=user_output
|