summaryrefslogtreecommitdiffstats
path: root/playbooks
diff options
context:
space:
mode:
Diffstat (limited to 'playbooks')
-rw-r--r--playbooks/adhoc/zabbix_setup/clean_zabbix.yml51
-rw-r--r--playbooks/adhoc/zabbix_setup/create_template.yml57
-rw-r--r--playbooks/adhoc/zabbix_setup/create_user.yml31
l---------playbooks/adhoc/zabbix_setup/filter_plugins1
l---------playbooks/adhoc/zabbix_setup/roles1
-rw-r--r--playbooks/adhoc/zabbix_setup/setup_zabbix.yml38
-rw-r--r--playbooks/adhoc/zabbix_setup/vars/template_heartbeat.yml11
-rw-r--r--playbooks/adhoc/zabbix_setup/vars/template_host.yml27
-rw-r--r--playbooks/adhoc/zabbix_setup/vars/template_master.yml27
-rw-r--r--playbooks/adhoc/zabbix_setup/vars/template_node.yml27
-rw-r--r--playbooks/adhoc/zabbix_setup/vars/template_os_linux.yml90
-rw-r--r--playbooks/adhoc/zabbix_setup/vars/template_router.yml27
12 files changed, 388 insertions, 0 deletions
diff --git a/playbooks/adhoc/zabbix_setup/clean_zabbix.yml b/playbooks/adhoc/zabbix_setup/clean_zabbix.yml
new file mode 100644
index 000000000..a31cbef65
--- /dev/null
+++ b/playbooks/adhoc/zabbix_setup/clean_zabbix.yml
@@ -0,0 +1,51 @@
+---
+- hosts: localhost
+ gather_facts: no
+ vars:
+ g_zserver: http://localhost/zabbix/api_jsonrpc.php
+ g_zuser: Admin
+ g_zpassword: zabbix
+ roles:
+ - ../../../roles/os_zabbix
+ post_tasks:
+
+ - zbx_template:
+ server: "{{ g_zserver }}"
+ user: "{{ g_zuser }}"
+ password: "{{ g_zpassword }}"
+ state: list
+ name: 'Template Heartbeat'
+ register: templ_heartbeat
+
+ - zbx_template:
+ server: "{{ g_zserver }}"
+ user: "{{ g_zuser }}"
+ password: "{{ g_zpassword }}"
+ state: list
+ name: 'Template App Zabbix Server'
+ register: templ_zabbix_server
+
+ - zbx_template:
+ server: "{{ g_zserver }}"
+ user: "{{ g_zuser }}"
+ password: "{{ g_zpassword }}"
+ state: list
+ name: 'Template App Zabbix Agent'
+ register: templ_zabbix_agent
+
+ - zbx_template:
+ server: "{{ g_zserver }}"
+ user: "{{ g_zuser }}"
+ password: "{{ g_zpassword }}"
+ state: list
+ register: templates
+
+ - debug: var=templ_heartbeat.results
+
+ - zbx_template:
+ server: "{{ g_zserver }}"
+ user: "{{ g_zuser }}"
+ password: "{{ g_zpassword }}"
+ 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/playbooks/adhoc/zabbix_setup/create_template.yml b/playbooks/adhoc/zabbix_setup/create_template.yml
new file mode 100644
index 000000000..50fff53b2
--- /dev/null
+++ b/playbooks/adhoc/zabbix_setup/create_template.yml
@@ -0,0 +1,57 @@
+---
+- debug: var=ctp_template
+
+- name: Create Template
+ zbx_template:
+ server: "{{ ctp_zserver }}"
+ user: "{{ ctp_zuser }}"
+ password: "{{ ctp_zpassword }}"
+ name: "{{ ctp_template.name }}"
+ register: ctp_created_template
+
+- debug: var=ctp_created_template
+
+#- name: Create Application
+# zbxapi:
+# server: "{{ ctp_zserver }}"
+# user: "{{ ctp_zuser }}"
+# password: "{{ ctp_zpassword }}"
+# zbx_class: Application
+# state: present
+# params:
+# name: "{{ ctp_template.application.name}}"
+# hostid: "{{ ctp_created_template.results[0].templateid }}"
+# search:
+# name: "{{ ctp_template.application.name}}"
+# register: ctp_created_application
+
+#- debug: var=ctp_created_application
+
+- name: Create Items
+ zbx_item:
+ server: "{{ ctp_zserver }}"
+ user: "{{ ctp_zuser }}"
+ password: "{{ ctp_zpassword }}"
+ key: "{{ item.key }}"
+ name: "{{ item.name | default(item.key, true) }}"
+ value_type: "{{ item.value_type | default('int') }}"
+ template_name: "{{ ctp_template.name }}"
+ with_items: ctp_template.zitems
+ register: ctp_created_items
+
+#- debug: var=ctp_created_items
+
+- name: Create Triggers
+ zbx_trigger:
+ server: "{{ ctp_zserver }}"
+ user: "{{ ctp_zuser }}"
+ password: "{{ ctp_zpassword }}"
+ description: "{{ item.description }}"
+ expression: "{{ item.expression }}"
+ priority: "{{ item.priority }}"
+ with_items: ctp_template.ztriggers
+ when: ctp_template.ztriggers is defined
+
+#- debug: var=ctp_created_triggers
+
+
diff --git a/playbooks/adhoc/zabbix_setup/create_user.yml b/playbooks/adhoc/zabbix_setup/create_user.yml
new file mode 100644
index 000000000..dd74798b7
--- /dev/null
+++ b/playbooks/adhoc/zabbix_setup/create_user.yml
@@ -0,0 +1,31 @@
+---
+# export PYTHONPATH='/usr/lib/python2.7/site-packages/:/home/kwoodson/git/openshift-tools'
+# ansible-playbook -e 'cli_password=zabbix' -e 'cli_new_password=new-zabbix' create_user.yml
+- hosts: localhost
+ gather_facts: no
+ vars_files:
+ - vars/template_heartbeat.yml
+ - vars/template_os_linux.yml
+ vars:
+ g_zserver: http://localhost/zabbix/api_jsonrpc.php
+ g_zuser: admin
+ g_zpassword: "{{ cli_password }}"
+ roles:
+ - ../../../roles/os_zabbix
+ post_tasks:
+ - zbx_user:
+ server: "{{ g_zserver }}"
+ user: "{{ g_zuser }}"
+ password: "{{ g_zpassword }}"
+ state: list
+ register: users
+
+ - debug: var=users
+
+ - name: Update zabbix creds for admin
+ zbx_user:
+ server: "{{ g_zserver }}"
+ user: "{{ g_zuser }}"
+ password: "{{ g_zpassword }}"
+ alias: Admin
+ passwd: "{{ cli_new_password | default(g_zpassword, true) }}"
diff --git a/playbooks/adhoc/zabbix_setup/filter_plugins b/playbooks/adhoc/zabbix_setup/filter_plugins
new file mode 120000
index 000000000..99a95e4ca
--- /dev/null
+++ b/playbooks/adhoc/zabbix_setup/filter_plugins
@@ -0,0 +1 @@
+../../../filter_plugins \ No newline at end of file
diff --git a/playbooks/adhoc/zabbix_setup/roles b/playbooks/adhoc/zabbix_setup/roles
new file mode 120000
index 000000000..e2b799b9d
--- /dev/null
+++ b/playbooks/adhoc/zabbix_setup/roles
@@ -0,0 +1 @@
+../../../roles/ \ No newline at end of file
diff --git a/playbooks/adhoc/zabbix_setup/setup_zabbix.yml b/playbooks/adhoc/zabbix_setup/setup_zabbix.yml
new file mode 100644
index 000000000..1729194b5
--- /dev/null
+++ b/playbooks/adhoc/zabbix_setup/setup_zabbix.yml
@@ -0,0 +1,38 @@
+---
+- hosts: localhost
+ gather_facts: no
+ vars_files:
+ - vars/template_heartbeat.yml
+ - vars/template_os_linux.yml
+ vars:
+ g_zserver: http://localhost/zabbix/api_jsonrpc.php
+ g_zuser: Admin
+ g_zpassword: zabbix
+ roles:
+ - ../../../roles/os_zabbix
+ post_tasks:
+ - zbx_template:
+ server: "{{ g_zserver }}"
+ user: "{{ g_zuser }}"
+ password: "{{ g_zpassword }}"
+ state: list
+ register: templates
+
+ - debug: var=templates
+
+ - name: Include Template
+ include: create_template.yml
+ vars:
+ ctp_template: "{{ g_template_heartbeat }}"
+ ctp_zserver: "{{ g_zserver }}"
+ ctp_zuser: "{{ g_zuser }}"
+ ctp_zpassword: "{{ g_zpassword }}"
+
+ - name: Include Template
+ include: create_template.yml
+ vars:
+ ctp_template: "{{ g_template_os_linux }}"
+ ctp_zserver: "{{ g_zserver }}"
+ ctp_zuser: "{{ g_zuser }}"
+ ctp_zpassword: "{{ g_zpassword }}"
+
diff --git a/playbooks/adhoc/zabbix_setup/vars/template_heartbeat.yml b/playbooks/adhoc/zabbix_setup/vars/template_heartbeat.yml
new file mode 100644
index 000000000..22cc75554
--- /dev/null
+++ b/playbooks/adhoc/zabbix_setup/vars/template_heartbeat.yml
@@ -0,0 +1,11 @@
+---
+g_template_heartbeat:
+ name: Template Heartbeat
+ zitems:
+ - name: Heartbeat Ping
+ hostid:
+ key: heartbeat.ping
+ ztriggers:
+ - description: 'Heartbeat.ping has failed on {HOST.NAME}'
+ expression: '{Template Heartbeat:heartbeat.ping.last()}<>0'
+ priority: avg
diff --git a/playbooks/adhoc/zabbix_setup/vars/template_host.yml b/playbooks/adhoc/zabbix_setup/vars/template_host.yml
new file mode 100644
index 000000000..e7cc667cb
--- /dev/null
+++ b/playbooks/adhoc/zabbix_setup/vars/template_host.yml
@@ -0,0 +1,27 @@
+---
+g_template_host:
+ params:
+ name: Template Host
+ host: Template Host
+ groups:
+ - groupid: 1 # FIXME (not real)
+ output: extend
+ search:
+ name: Template Host
+ zitems:
+ - name: Host Ping
+ hostid:
+ key_: host.ping
+ type: 2
+ value_type: 0
+ output: extend
+ search:
+ key_: host.ping
+ ztriggers:
+ - description: 'Host ping has failed on {HOST.NAME}'
+ expression: '{Template Host:host.ping.last()}<>0'
+ priority: 3
+ searchWildcardsEnabled: True
+ search:
+ description: 'Host ping has failed on*'
+ expandExpression: True
diff --git a/playbooks/adhoc/zabbix_setup/vars/template_master.yml b/playbooks/adhoc/zabbix_setup/vars/template_master.yml
new file mode 100644
index 000000000..5f9b41a4f
--- /dev/null
+++ b/playbooks/adhoc/zabbix_setup/vars/template_master.yml
@@ -0,0 +1,27 @@
+---
+g_template_master:
+ params:
+ name: Template Master
+ host: Template Master
+ groups:
+ - groupid: 1 # FIXME (not real)
+ output: extend
+ search:
+ name: Template Master
+ zitems:
+ - name: Master Etcd Ping
+ hostid:
+ key_: master.etcd.ping
+ type: 2
+ value_type: 0
+ output: extend
+ search:
+ key_: master.etcd.ping
+ ztriggers:
+ - description: 'Master Etcd ping has failed on {HOST.NAME}'
+ expression: '{Template Master:master.etcd.ping.last()}<>0'
+ priority: 3
+ searchWildcardsEnabled: True
+ search:
+ description: 'Master Etcd ping has failed on*'
+ expandExpression: True
diff --git a/playbooks/adhoc/zabbix_setup/vars/template_node.yml b/playbooks/adhoc/zabbix_setup/vars/template_node.yml
new file mode 100644
index 000000000..98c343a24
--- /dev/null
+++ b/playbooks/adhoc/zabbix_setup/vars/template_node.yml
@@ -0,0 +1,27 @@
+---
+g_template_node:
+ params:
+ name: Template Node
+ host: Template Node
+ groups:
+ - groupid: 1 # FIXME (not real)
+ output: extend
+ search:
+ name: Template Node
+ zitems:
+ - name: Kubelet Ping
+ hostid:
+ key_: kubelet.ping
+ type: 2
+ value_type: 0
+ output: extend
+ search:
+ key_: kubelet.ping
+ ztriggers:
+ - description: 'Kubelet ping has failed on {HOST.NAME}'
+ expression: '{Template Node:kubelet.ping.last()}<>0'
+ priority: 3
+ searchWildcardsEnabled: True
+ search:
+ description: 'Kubelet ping has failed on*'
+ expandExpression: True
diff --git a/playbooks/adhoc/zabbix_setup/vars/template_os_linux.yml b/playbooks/adhoc/zabbix_setup/vars/template_os_linux.yml
new file mode 100644
index 000000000..9cc038ffa
--- /dev/null
+++ b/playbooks/adhoc/zabbix_setup/vars/template_os_linux.yml
@@ -0,0 +1,90 @@
+---
+g_template_os_linux:
+ name: Template OS Linux
+ zitems:
+ - key: kernel.uname.sysname
+ value_type: string
+
+ - key: kernel.all.cpu.wait.total
+ value_type: int
+
+ - key: kernel.all.cpu.irq.hard
+ value_type: int
+
+ - key: kernel.all.cpu.idle
+ value_type: int
+
+ - key: kernel.uname.distro
+ value_type: string
+
+ - key: kernel.uname.nodename
+ value_type: string
+
+ - key: kernel.all.cpu.irq.soft
+ value_type: int
+
+ - key: kernel.all.load.15_minute
+ value_type: float
+
+ - key: kernel.all.cpu.sys
+ value_type: int
+
+ - key: kernel.all.load.5_minute
+ value_type: float
+
+ - key: mem.freemem
+ value_type: int
+
+ - key: kernel.all.cpu.nice
+ value_type: int
+
+ - key: mem.util.bufmem
+ value_type: int
+
+ - key: swap.used
+ value_type: int
+
+ - key: kernel.all.load.1_minute
+ value_type: float
+
+ - key: kernel.uname.version
+ value_type: string
+
+ - key: swap.length
+ value_type: int
+
+ - key: mem.physmem
+ value_type: int
+
+ - key: kernel.all.uptime
+ value_type: int
+
+ - key: swap.free
+ value_type: int
+
+ - key: mem.util.used
+ value_type: int
+
+ - key: kernel.all.cpu.user
+ value_type: int
+
+ - key: kernel.uname.machine
+ value_type: string
+
+ - key: hinv.ncpu
+ value_type: int
+
+ - key: mem.util.cached
+ value_type: int
+
+ - key: kernel.all.cpu.steal
+ value_type: int
+
+ - key: kernel.all.pswitch
+ value_type: int
+
+ - key: kernel.uname.release
+ value_type: string
+
+ - key: proc.nprocs
+ value_type: int
diff --git a/playbooks/adhoc/zabbix_setup/vars/template_router.yml b/playbooks/adhoc/zabbix_setup/vars/template_router.yml
new file mode 100644
index 000000000..4dae7da1e
--- /dev/null
+++ b/playbooks/adhoc/zabbix_setup/vars/template_router.yml
@@ -0,0 +1,27 @@
+---
+g_template_router:
+ params:
+ name: Template Router
+ host: Template Router
+ groups:
+ - groupid: 1 # FIXME (not real)
+ output: extend
+ search:
+ name: Template Router
+ zitems:
+ - name: Router Backends down
+ hostid:
+ key_: router.backends.down
+ type: 2
+ value_type: 0
+ output: extend
+ search:
+ key_: router.backends.down
+ ztriggers:
+ - description: 'Number of router backends down on {HOST.NAME}'
+ expression: '{Template Router:router.backends.down.last()}<>0'
+ priority: 3
+ searchWildcardsEnabled: True
+ search:
+ description: 'Number of router backends down on {HOST.NAME}'
+ expandExpression: True