summaryrefslogtreecommitdiffstats
path: root/roles/os_zabbix/tasks
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2015-08-21 17:44:30 -0400
committerKenny Woodson <kwoodson@redhat.com>2015-08-27 09:35:19 -0400
commit3012985b20e44c0ca4f7cce5a70926f518ec19c5 (patch)
tree757de1c6a7a28303f950ca99c381075f20ef7ffa /roles/os_zabbix/tasks
parent2f5486c7174eeacdd52938442daa2ddfa6a8e277 (diff)
downloadopenshift-3012985b20e44c0ca4f7cce5a70926f518ec19c5.tar.gz
openshift-3012985b20e44c0ca4f7cce5a70926f518ec19c5.tar.bz2
openshift-3012985b20e44c0ca4f7cce5a70926f518ec19c5.tar.xz
openshift-3012985b20e44c0ca4f7cce5a70926f518ec19c5.zip
Updates for zbx ans module
Diffstat (limited to 'roles/os_zabbix/tasks')
-rw-r--r--roles/os_zabbix/tasks/clean_zabbix.yml47
-rw-r--r--roles/os_zabbix/tasks/create_template.yml56
-rw-r--r--roles/os_zabbix/tasks/create_user.yml11
-rw-r--r--roles/os_zabbix/tasks/main.yml30
4 files changed, 144 insertions, 0 deletions
diff --git a/roles/os_zabbix/tasks/clean_zabbix.yml b/roles/os_zabbix/tasks/clean_zabbix.yml
new file mode 100644
index 000000000..1bcc07d42
--- /dev/null
+++ b/roles/os_zabbix/tasks/clean_zabbix.yml
@@ -0,0 +1,47 @@
+---
+- name: CLEAN List template for heartbeat
+ zbx_template:
+ server: "{{ server }}"
+ user: "{{ user }}"
+ password: "{{ password }}"
+ state: list
+ name: 'Template Heartbeat'
+ register: templ_heartbeat
+
+- name: CLEAN List template app zabbix server
+ zbx_template:
+ server: "{{ server }}"
+ user: "{{ user }}"
+ password: "{{ password }}"
+ state: list
+ name: 'Template App Zabbix Server'
+ register: templ_zabbix_server
+
+- name: CLEAN List template app zabbix server
+ zbx_template:
+ server: "{{ server }}"
+ user: "{{ user }}"
+ password: "{{ password }}"
+ state: list
+ name: 'Template App Zabbix Agent'
+ register: templ_zabbix_agent
+
+- name: CLEAN List all templates
+ zbx_template:
+ server: "{{ server }}"
+ user: "{{ user }}"
+ password: "{{ password }}"
+ state: list
+ register: templates
+
+- debug: var=templ_heartbeat.results
+
+- name: Remove templates if heartbeat template is missing
+ zbx_template:
+ server: "{{ server }}"
+ user: "{{ user }}"
+ password: "{{ password }}"
+ name: "{{ item }}"
+ state: absent
+ with_items: "{{ templates.results | difference(templ_zabbix_agent.results) | difference(templ_zabbix_server.results) | oo_collect('host') }}"
+ when: templ_heartbeat.results | length == 0
diff --git a/roles/os_zabbix/tasks/create_template.yml b/roles/os_zabbix/tasks/create_template.yml
new file mode 100644
index 000000000..070390aba
--- /dev/null
+++ b/roles/os_zabbix/tasks/create_template.yml
@@ -0,0 +1,56 @@
+---
+- debug: var=template
+
+- name: Template Create Template
+ zbx_template:
+ server: "{{ server }}"
+ user: "{{ user }}"
+ password: "{{ password }}"
+ name: "{{ template.name }}"
+ register: created_template
+
+- debug: var=created_template
+
+- name: Create Application
+ zbx_application:
+ server: "{{ server }}"
+ user: "{{ user }}"
+ password: "{{ password }}"
+ name: "{{ item }}"
+ template_name: "{{ template.name }}"
+ with_items: template.zapplications
+ register: created_application
+ when: template.zapplications is defined
+
+- debug: var=created_application
+
+- name: Create Items
+ zbx_item:
+ server: "{{ server }}"
+ user: "{{ user }}"
+ 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.application }}"
+ with_items: template.zitems
+ register: created_items
+ when: template.zitems is defined
+
+#- debug: var=ctp_created_items
+
+- name: Create Triggers
+ zbx_trigger:
+ server: "{{ server }}"
+ user: "{{ user }}"
+ 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/os_zabbix/tasks/create_user.yml b/roles/os_zabbix/tasks/create_user.yml
new file mode 100644
index 000000000..1f752a9e1
--- /dev/null
+++ b/roles/os_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
diff --git a/roles/os_zabbix/tasks/main.yml b/roles/os_zabbix/tasks/main.yml
new file mode 100644
index 000000000..06c0a09fc
--- /dev/null
+++ b/roles/os_zabbix/tasks/main.yml
@@ -0,0 +1,30 @@
+---
+- name: Main List all templates
+ zbx_template:
+ server: "{{ ozb_server }}"
+ user: "{{ ozb_user }}"
+ password: "{{ ozb_password }}"
+ state: list
+ register: templates
+
+- debug: var=templates
+
+- include_vars: template_heartbeat.yml
+- include_vars: template_os_linux.yml
+
+- name: Include Template Heartbeat
+ include: create_template.yml
+ vars:
+ template: "{{ g_template_heartbeat }}"
+ server: "{{ ozb_server }}"
+ user: "{{ ozb_user }}"
+ password: "{{ ozb_password }}"
+
+#- name: Include Template os_linux
+# include: create_template.yml
+# vars:
+# template: "{{ g_template_os_linux }}"
+# server: "{{ ozb_server }}"
+# user: "{{ ozb_user }}"
+# password: "{{ ozb_password }}"
+