summaryrefslogtreecommitdiffstats
path: root/roles/lib_zabbix/library/test.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/lib_zabbix/library/test.yml')
-rw-r--r--roles/lib_zabbix/library/test.yml131
1 files changed, 131 insertions, 0 deletions
diff --git a/roles/lib_zabbix/library/test.yml b/roles/lib_zabbix/library/test.yml
new file mode 100644
index 000000000..cedace1a0
--- /dev/null
+++ b/roles/lib_zabbix/library/test.yml
@@ -0,0 +1,131 @@
+---
+# 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:8080/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 a discoveryrule
+ zbx_discoveryrule:
+ server: "{{ zbx_server }}"
+ user: "{{ zbx_user }}"
+ password: "{{ zbx_password }}"
+ name: test discoverule
+ key: test_listener
+ template_name: test template
+ lifetime: 14
+ register: discoveryrule
+
+ - debug: var=discoveryrule
+
+ - name: Create an itemprototype
+ zbx_itemprototype:
+ server: "{{ zbx_server }}"
+ user: "{{ zbx_user }}"
+ password: "{{ zbx_password }}"
+ name: 'Test itemprototype on {#TEST_LISTENER}'
+ key: 'test[{#TEST_LISTENER}]'
+ template_name: test template
+ discoveryrule_name: test discoverule
+ register: itemproto
+
+ - debug: var=itemproto
+
+ - name: Create an application
+ zbx_application:
+ server: "{{ zbx_server }}"
+ user: "{{ zbx_user }}"
+ password: "{{ zbx_password }}"
+ name: 'Test App'
+ template_name: "test template"
+ register: item_output
+
+ - name: Create an item
+ zbx_item:
+ server: "{{ zbx_server }}"
+ user: "{{ zbx_user }}"
+ password: "{{ zbx_password }}"
+ name: 'test item'
+ key: 'kenny.item.1'
+ applications:
+ - 'Test App'
+ template_name: "test template"
+ 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'
+ description: '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'
+ template_names:
+ - test template
+ hostgroup_names:
+ - 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