summaryrefslogtreecommitdiffstats
path: root/roles/lib_zabbix/tasks/create_template.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/lib_zabbix/tasks/create_template.yml')
-rw-r--r--roles/lib_zabbix/tasks/create_template.yml98
1 files changed, 95 insertions, 3 deletions
diff --git a/roles/lib_zabbix/tasks/create_template.yml b/roles/lib_zabbix/tasks/create_template.yml
index fd0cdd46f..783249c3a 100644
--- a/roles/lib_zabbix/tasks/create_template.yml
+++ b/roles/lib_zabbix/tasks/create_template.yml
@@ -9,7 +9,8 @@
- set_fact:
- lzbx_applications: "{{ template.zitems | oo_select_keys_from_list(['applications']) | oo_flatten | unique }}"
+ lzbx_item_applications: "{{ template.zitems | default([], True) | oo_select_keys_from_list(['applications']) | oo_flatten | unique }}"
+ lzbx_itemprototype_applications: "{{ template.zitemprototypes | default([], True) | oo_select_keys_from_list(['applications']) | oo_flatten | unique }}"
- name: Create Application
zbx_application:
@@ -18,9 +19,11 @@
zbx_password: "{{ password }}"
name: "{{ item }}"
template_name: "{{ template.name }}"
- with_items: lzbx_applications
+ with_items:
+ - "{{ lzbx_item_applications }}"
+ - "{{ lzbx_itemprototype_applications }}"
register: created_application
- when: template.zitems is defined
+ when: template.zitems is defined or template.zitemprototypes is defined
- name: Create Items
zbx_item:
@@ -30,11 +33,15 @@
key: "{{ item.key }}"
name: "{{ item.name | default(item.key, true) }}"
value_type: "{{ item.value_type | default('int') }}"
+ data_type: "{{ item.data_type | default('decimal') }}"
description: "{{ item.description | default('', True) }}"
multiplier: "{{ item.multiplier | default('', True) }}"
units: "{{ item.units | default('', True) }}"
template_name: "{{ template.name }}"
applications: "{{ item.applications }}"
+ zabbix_type: "{{ item.zabbix_type | default('trapper') }}"
+ interval: "{{ item.interval | default(60, True) }}"
+ delta: "{{ item.delta | default(0, True) }}"
with_items: template.zitems
register: created_items
when: template.zitems is defined
@@ -50,5 +57,90 @@
expression: "{{ item.expression }}"
priority: "{{ item.priority }}"
url: "{{ item.url | default(None, True) }}"
+ status: "{{ item.status | default('', True) }}"
with_items: template.ztriggers
when: template.ztriggers is defined
+
+- name: Create Actions
+ zbx_action:
+ zbx_server: "{{ server }}"
+ zbx_user: "{{ user }}"
+ zbx_password: "{{ password }}"
+ state: "{{ item.state | default('present', True) }}"
+ name: "{{ item.name }}"
+ status: "{{ item.status | default('enabled', True) }}"
+ escalation_time: "{{ item.escalation_time }}"
+ conditions_filter: "{{ item.conditions_filter }}"
+ operations: "{{ item.operations }}"
+ with_items: template.zactions
+ when: template.zactions is defined
+
+- name: Create Discoveryrules
+ zbx_discoveryrule:
+ zbx_server: "{{ server }}"
+ zbx_user: "{{ user }}"
+ zbx_password: "{{ password }}"
+ name: "{{ item.name }}"
+ key: "{{ item.key }}"
+ lifetime: "{{ item.lifetime }}"
+ template_name: "{{ template.name }}"
+ description: "{{ item.description | default('', True) }}"
+ with_items: template.zdiscoveryrules
+ when: template.zdiscoveryrules is defined
+
+- name: Create Item Prototypes
+ zbx_itemprototype:
+ zbx_server: "{{ server }}"
+ zbx_user: "{{ user }}"
+ zbx_password: "{{ password }}"
+ name: "{{ item.name }}"
+ key: "{{ item.key }}"
+ discoveryrule_key: "{{ item.discoveryrule_key }}"
+ value_type: "{{ item.value_type }}"
+ data_type: "{{ item.data_type | default('decimal') }}"
+ template_name: "{{ template.name }}"
+ applications: "{{ item.applications }}"
+ description: "{{ item.description | default('', True) }}"
+ multiplier: "{{ item.multiplier | default('', True) }}"
+ units: "{{ item.units | default('', True) }}"
+ interval: "{{ item.interval | default(60, True) }}"
+ delta: "{{ item.delta | default(0, True) }}"
+ with_items: template.zitemprototypes
+ when: template.zitemprototypes is defined
+
+- name: Create Trigger Prototypes
+ zbx_triggerprototype:
+ zbx_server: "{{ server }}"
+ zbx_user: "{{ user }}"
+ zbx_password: "{{ password }}"
+ name: "{{ item.name }}"
+ expression: "{{ item.expression }}"
+ url: "{{ item.url | default('', True) }}"
+ priority: "{{ item.priority | default('average', True) }}"
+ description: "{{ item.description | default('', True) }}"
+ with_items: template.ztriggerprototypes
+ when: template.ztriggerprototypes is defined
+
+- name: Create Graphs
+ zbx_graph:
+ zbx_server: "{{ server }}"
+ zbx_user: "{{ user }}"
+ zbx_password: "{{ password }}"
+ name: "{{ item.name }}"
+ height: "{{ item.height }}"
+ width: "{{ item.width }}"
+ graph_items: "{{ item.graph_items }}"
+ with_items: template.zgraphs
+ when: template.zgraphs is defined
+
+- name: Create Graph Prototypes
+ zbx_graphprototype:
+ zbx_server: "{{ server }}"
+ zbx_user: "{{ user }}"
+ zbx_password: "{{ password }}"
+ name: "{{ item.name }}"
+ height: "{{ item.height }}"
+ width: "{{ item.width }}"
+ graph_items: "{{ item.graph_items }}"
+ with_items: template.zgraphprototypes
+ when: template.zgraphprototypes is defined