summaryrefslogtreecommitdiffstats
path: root/roles/lib_zabbix/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/lib_zabbix/tasks')
-rw-r--r--roles/lib_zabbix/tasks/create_template.yml61
-rw-r--r--roles/lib_zabbix/tasks/create_user.yml11
2 files changed, 72 insertions, 0 deletions
diff --git a/roles/lib_zabbix/tasks/create_template.yml b/roles/lib_zabbix/tasks/create_template.yml
new file mode 100644
index 000000000..022ca52f2
--- /dev/null
+++ b/roles/lib_zabbix/tasks/create_template.yml
@@ -0,0 +1,61 @@
+---
+- debug: var=template
+
+- name: Template Create Template
+ zbx_template:
+ zbx_server: "{{ server }}"
+ zbx_user: "{{ user }}"
+ zbx_password: "{{ password }}"
+ name: "{{ template.name }}"
+ register: created_template
+
+- debug: var=created_template
+
+- set_fact:
+ lzbx_applications: "{{ template.zitems | oo_select_keys_from_list(['applications']) | oo_flatten | unique }}"
+
+- debug: var=lzbx_applications
+
+- name: Create Application
+ zbx_application:
+ zbx_server: "{{ server }}"
+ zbx_user: "{{ user }}"
+ zbx_password: "{{ password }}"
+ name: "{{ item }}"
+ template_name: "{{ template.name }}"
+ with_items: lzbx_applications
+ register: created_application
+ when: template.zitems is defined
+
+- debug: var=created_application
+
+- name: Create Items
+ zbx_item:
+ zbx_server: "{{ server }}"
+ zbx_user: "{{ user }}"
+ zbx_password: "{{ password }}"
+ key: "{{ item.key }}"
+ name: "{{ item.name | default(item.key, true) }}"
+ value_type: "{{ item.value_type | default('int') }}"
+ template_name: "{{ template.name }}"
+ applications: "{{ item.applications }}"
+ with_items: template.zitems
+ register: created_items
+ when: template.zitems is defined
+
+#- debug: var=ctp_created_items
+
+- name: Create Triggers
+ zbx_trigger:
+ zbx_server: "{{ server }}"
+ zbx_user: "{{ user }}"
+ zbx_password: "{{ password }}"
+ description: "{{ item.description }}"
+ expression: "{{ item.expression }}"
+ priority: "{{ item.priority }}"
+ with_items: template.ztriggers
+ when: template.ztriggers is defined
+
+#- debug: var=ctp_created_triggers
+
+
diff --git a/roles/lib_zabbix/tasks/create_user.yml b/roles/lib_zabbix/tasks/create_user.yml
new file mode 100644
index 000000000..1f752a9e1
--- /dev/null
+++ b/roles/lib_zabbix/tasks/create_user.yml
@@ -0,0 +1,11 @@
+---
+- name: Update zabbix credentialss for a user
+ zbx_user:
+ server: "{{ ozb_server }}"
+ user: "{{ ozb_user }}"
+ password: "{{ ozb_password }}"
+ alias: "{{ ozb_username }}"
+ passwd: "{{ ozb_new_password | default(ozb_password, true) }}"
+ register: user
+
+- debug: var=user.results