diff options
-rw-r--r-- | filter_plugins/oo_filters.py | 10 | ||||
-rw-r--r-- | filter_plugins/oo_zabbix_filters.py | 79 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/clean_zabbix.yml | 66 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/create_app.yml | 34 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/create_application.yml | 18 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/create_template.yml | 59 | ||||
l--------- | playbooks/adhoc/zabbix_setup/filter_plugins | 1 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/setup_zabbix.yml | 41 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/vars/template_heartbeat.yml | 33 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/vars/template_host.yml | 27 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/vars/template_master.yml | 27 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/vars/template_node.yml | 27 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/vars/template_os_linux.yml | 248 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/vars/template_router.yml | 27 | ||||
-rw-r--r-- | roles/openshift_master_certificates/tasks/main.yml | 16 |
15 files changed, 703 insertions, 10 deletions
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py index 88e86f67c..47033a88e 100644 --- a/filter_plugins/oo_filters.py +++ b/filter_plugins/oo_filters.py @@ -232,15 +232,6 @@ class FilterModule(object): return [x for x in data if x[filter_attr]] @staticmethod - def oo_build_zabbix_list_dict(values, string): - ''' Build a list of dicts with string as key for each value - ''' - rval = [] - for value in values: - rval.append({string: value}) - return rval - - @staticmethod def oo_parse_heat_stack_outputs(data): ''' Formats the HEAT stack output into a usable form @@ -320,6 +311,5 @@ class FilterModule(object): "oo_combine_key_value": self.oo_combine_key_value, "oo_split": self.oo_split, "oo_filter_list": self.oo_filter_list, - "oo_build_zabbix_list_dict": self.oo_build_zabbix_list_dict, "oo_parse_heat_stack_outputs": self.oo_parse_heat_stack_outputs } diff --git a/filter_plugins/oo_zabbix_filters.py b/filter_plugins/oo_zabbix_filters.py new file mode 100644 index 000000000..a473993a2 --- /dev/null +++ b/filter_plugins/oo_zabbix_filters.py @@ -0,0 +1,79 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# vim: expandtab:tabstop=4:shiftwidth=4 +''' +Custom zabbix filters for use in openshift-ansible +''' + +import pdb + +class FilterModule(object): + ''' Custom zabbix ansible filters ''' + + @staticmethod + def create_data(data, results, key, new_key): + '''Take a dict, filter through results and add results['key'] to dict + ''' + new_list = [app[key] for app in results] + data[new_key] = new_list + return data + + @staticmethod + def oo_set_zbx_trigger_triggerid(item, trigger_results): + '''Set zabbix trigger id from trigger results + ''' + if isinstance(trigger_results, list): + item['triggerid'] = trigger_results[0]['triggerid'] + return item + + item['triggerid'] = trigger_results['triggerids'][0] + return item + + @staticmethod + def oo_set_zbx_item_hostid(item, template_results): + ''' Set zabbix host id from template results + ''' + if isinstance(template_results, list): + item['hostid'] = template_results[0]['templateid'] + return item + + item['hostid'] = template_results['templateids'][0] + return item + + @staticmethod + def oo_pdb(arg): + ''' This pops you into a pdb instance where arg is the data passed in + from the filter. + Ex: "{{ hostvars | oo_pdb }}" + ''' + pdb.set_trace() + return arg + + @staticmethod + def select_by_name(ans_data, data): + ''' test + ''' + for zabbix_item in data: + if ans_data['name'] == zabbix_item: + data[zabbix_item]['params']['hostid'] = ans_data['templateid'] + return data[zabbix_item]['params'] + return None + + @staticmethod + def oo_build_zabbix_list_dict(values, string): + ''' Build a list of dicts with string as key for each value + ''' + rval = [] + for value in values: + rval.append({string: value}) + return rval + + def filters(self): + ''' returns a mapping of filters to methods ''' + return { + "select_by_name": self.select_by_name, + "oo_set_zbx_item_hostid": self.oo_set_zbx_item_hostid, + "oo_set_zbx_trigger_triggerid": self.oo_set_zbx_trigger_triggerid, + "oo_build_zabbix_list_dict": self.oo_build_zabbix_list_dict, + "create_data": self.create_data, + } diff --git a/playbooks/adhoc/zabbix_setup/clean_zabbix.yml b/playbooks/adhoc/zabbix_setup/clean_zabbix.yml new file mode 100644 index 000000000..bd71e6d1d --- /dev/null +++ b/playbooks/adhoc/zabbix_setup/clean_zabbix.yml @@ -0,0 +1,66 @@ +--- +- hosts: localhost + gather_facts: no + vars: + g_zserver: http://oso-rhel7-zabbix-web.kwoodsontest2.opstest.online.openshift.com/zabbix/api_jsonrpc.php + g_zuser: Admin + g_zpassword: zabbix + roles: + - ../roles/os_zabbix + post_tasks: + + - zbxapi: + server: "{{ g_zserver }}" + user: "{{ g_zuser }}" + password: "{{ g_zpassword }}" + zbx_class: Template + state: list + params: + output: extend + search: + host: 'Template Heartbeat' + register: templ_heartbeat + + - zbxapi: + server: "{{ g_zserver }}" + user: "{{ g_zuser }}" + password: "{{ g_zpassword }}" + zbx_class: Template + state: list + params: + output: extend + search: + host: 'Template App Zabbix Server' + register: templ_zabbix_server + + - zbxapi: + server: "{{ g_zserver }}" + user: "{{ g_zuser }}" + password: "{{ g_zpassword }}" + zbx_class: Template + state: list + params: + output: extend + search: + host: 'Template App Zabbix Agent' + register: templ_zabbix_agent + + - zbxapi: + server: "{{ g_zserver }}" + user: "{{ g_zuser }}" + password: "{{ g_zpassword }}" + zbx_class: Template + state: list + register: templates + + - debug: var=templ_heartbeat.results + + - zbxapi: + server: "{{ g_zserver }}" + user: "{{ g_zuser }}" + password: "{{ g_zpassword }}" + zbx_class: Template + state: absent + params: "{{templates.results | difference(templ_zabbix_agent.results) | difference(templ_zabbix_server.results) | oo_collect('templateid') }}" + register: template_results + when: templ_heartbeat.results | length == 0 diff --git a/playbooks/adhoc/zabbix_setup/create_app.yml b/playbooks/adhoc/zabbix_setup/create_app.yml new file mode 100644 index 000000000..3a08b2301 --- /dev/null +++ b/playbooks/adhoc/zabbix_setup/create_app.yml @@ -0,0 +1,34 @@ +--- +- hosts: localhost + gather_facts: no + vars_files: + - vars/template_heartbeat.yml + - vars/template_os_linux.yml + vars: + g_zserver: http://oso-rhel7-zabbix-web.kwoodsontest2.opstest.online.openshift.com/zabbix/api_jsonrpc.php + g_zuser: Admin + g_zpassword: zabbix + roles: + - ../roles/os_zabbix + post_tasks: + - zbxapi: + server: "{{ g_zserver }}" + user: "{{ g_zuser }}" + password: "{{ g_zpassword }}" + zbx_class: Template + state: list + params: + output: extend + register: templates + + - debug: var=templates + + - name: Create app + include: create_application.yml + vars: + ctp_template: "{{ g_template_heartbeat }}" + ctp_zserver: "{{ g_zserver }}" + ctp_zuser: "{{ g_zuser }}" + ctp_zpassword: "{{ g_zpassword }}" + + diff --git a/playbooks/adhoc/zabbix_setup/create_application.yml b/playbooks/adhoc/zabbix_setup/create_application.yml new file mode 100644 index 000000000..aa6c40ed8 --- /dev/null +++ b/playbooks/adhoc/zabbix_setup/create_application.yml @@ -0,0 +1,18 @@ +--- +- debug: var=ctp_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: 10085 + search: + name: "{{ ctp_template.application['name'] }}" + register: ctp_created_application + +- debug: var=ctp_created_application diff --git a/playbooks/adhoc/zabbix_setup/create_template.yml b/playbooks/adhoc/zabbix_setup/create_template.yml new file mode 100644 index 000000000..b055e78eb --- /dev/null +++ b/playbooks/adhoc/zabbix_setup/create_template.yml @@ -0,0 +1,59 @@ +--- +- debug: var=ctp_template + +- name: Create Template + zbxapi: + server: "{{ ctp_zserver }}" + user: "{{ ctp_zuser }}" + password: "{{ ctp_zpassword }}" + zbx_class: Template + state: present + params: "{{ ctp_template.params }}" + register: ctp_created_templates + +- debug: var=ctp_created_templates + +#- 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_templates.results[0].templateid }}" +# search: +# name: "{{ ctp_template.application.name}}" +# register: ctp_created_application + +#- debug: var=ctp_created_application + +- name: Create Items + zbxapi: + server: "{{ ctp_zserver }}" + user: "{{ ctp_zuser }}" + password: "{{ ctp_zpassword }}" + zbx_class: Item + state: present + params: "{{ item | oo_set_zbx_item_hostid(ctp_created_templates.results) }}" + with_items: ctp_template.zitems + register: ctp_created_items + +#- debug: var=ctp_created_items + +- name: Create Triggers + zbxapi: + server: "{{ ctp_zserver }}" + user: "{{ ctp_zuser }}" + password: "{{ ctp_zpassword }}" + zbx_class: Trigger + state: present + params: "{{ item }}" + with_items: ctp_template.ztriggers + register: ctp_created_triggers + when: ctp_template.ztriggers is defined + +#- debug: var=ctp_created_triggers + + 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/setup_zabbix.yml b/playbooks/adhoc/zabbix_setup/setup_zabbix.yml new file mode 100644 index 000000000..286f699e5 --- /dev/null +++ b/playbooks/adhoc/zabbix_setup/setup_zabbix.yml @@ -0,0 +1,41 @@ +--- +- hosts: localhost + gather_facts: no + vars_files: + - vars/template_heartbeat.yml + - vars/template_os_linux.yml + vars: + g_zserver: http://oso-rhel7-zabbix-web.kwoodsontest2.opstest.online.openshift.com/zabbix/api_jsonrpc.php + g_zuser: Admin + g_zpassword: zabbix + roles: + - ../roles/os_zabbix + post_tasks: + - zbxapi: + server: "{{ g_zserver }}" + user: "{{ g_zuser }}" + password: "{{ g_zpassword }}" + zbx_class: Template + state: list + params: + output: extend + 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..9d6145ec4 --- /dev/null +++ b/playbooks/adhoc/zabbix_setup/vars/template_heartbeat.yml @@ -0,0 +1,33 @@ +--- +g_template_heartbeat: + application: + name: Heartbeat +#output: extend + search: + name: Heartbeat + params: + name: Template Heartbeat + host: Template Heartbeat + groups: + - groupid: 1 # FIXME (not real) + output: extend + search: + name: Template Heartbeat + zitems: + - name: Heartbeat Ping + hostid: + key_: heartbeat.ping + type: 2 + value_type: 1 + output: extend + search: + key_: heartbeat.ping + selectApplications: extend + ztriggers: + - description: 'Heartbeat.ping has failed on {HOST.NAME}' + expression: '{Template Heartbeat:heartbeat.ping.last()}<>0' + priority: 3 + searchWildcardsEnabled: True + search: + description: 'Heartbeat.ping has failed on*' + expandExpression: True 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..b89711632 --- /dev/null +++ b/playbooks/adhoc/zabbix_setup/vars/template_os_linux.yml @@ -0,0 +1,248 @@ +--- +g_template_os_linux: + application: + name: OS Linux + output: extend + search: + name: OS Linux + params: + name: Template OS Linux + host: Template OS Linux + groups: + - groupid: 1 # FIXME (not real) + output: extend + search: + name: Template OS Linux + zitems: + - hostid: null + key_: kernel.uname.sysname + name: kernel.uname.sysname + search: + key_: kernel.uname.sysname + type: 2 + value_type: 4 + selectApplications: extend + - hostid: null + key_: kernel.all.cpu.wait.total + name: kernel.all.cpu.wait.total + search: + key_: kernel.all.cpu.wait.total + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: kernel.all.cpu.irq.hard + name: kernel.all.cpu.irq.hard + search: + key_: kernel.all.cpu.irq.hard + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: kernel.all.cpu.idle + name: kernel.all.cpu.idle + search: + key_: kernel.all.cpu.idle + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: kernel.uname.distro + name: kernel.uname.distro + search: + key_: kernel.uname.distro + type: 2 + value_type: 4 + selectApplications: extend + - hostid: null + key_: kernel.uname.nodename + name: kernel.uname.nodename + search: + key_: kernel.uname.nodename + type: 2 + value_type: 4 + selectApplications: extend + - hostid: null + key_: kernel.all.cpu.irq.soft + name: kernel.all.cpu.irq.soft + search: + key_: kernel.all.cpu.irq.soft + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: kernel.all.load.15_minute + name: kernel.all.load.15_minute + search: + key_: kernel.all.load.15_minute + type: 2 + value_type: 0 + selectApplications: extend + - hostid: null + key_: kernel.all.cpu.sys + name: kernel.all.cpu.sys + search: + key_: kernel.all.cpu.sys + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: kernel.all.load.5_minute + name: kernel.all.load.5_minute + search: + key_: kernel.all.load.5_minute + type: 2 + value_type: 0 + selectApplications: extend + - hostid: null + key_: mem.freemem + name: mem.freemem + search: + key_: mem.freemem + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: kernel.all.cpu.nice + name: kernel.all.cpu.nice + search: + key_: kernel.all.cpu.nice + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: mem.util.bufmem + name: mem.util.bufmem + search: + key_: mem.util.bufmem + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: swap.used + name: swap.used + search: + key_: swap.used + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: kernel.all.load.1_minute + name: kernel.all.load.1_minute + search: + key_: kernel.all.load.1_minute + type: 2 + value_type: 0 + selectApplications: extend + - hostid: null + key_: kernel.uname.version + name: kernel.uname.version + search: + key_: kernel.uname.version + type: 2 + value_type: 4 + selectApplications: extend + - hostid: null + key_: swap.length + name: swap.length + search: + key_: swap.length + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: mem.physmem + name: mem.physmem + search: + key_: mem.physmem + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: kernel.all.uptime + name: kernel.all.uptime + search: + key_: kernel.all.uptime + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: swap.free + name: swap.free + search: + key_: swap.free + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: mem.util.used + name: mem.util.used + search: + key_: mem.util.used + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: kernel.all.cpu.user + name: kernel.all.cpu.user + search: + key_: kernel.all.cpu.user + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: kernel.uname.machine + name: kernel.uname.machine + search: + key_: kernel.uname.machine + type: 2 + value_type: 4 + selectApplications: extend + - hostid: null + key_: hinv.ncpu + name: hinv.ncpu + search: + key_: hinv.ncpu + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: mem.util.cached + name: mem.util.cached + search: + key_: mem.util.cached + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: kernel.all.cpu.steal + name: kernel.all.cpu.steal + search: + key_: kernel.all.cpu.steal + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: kernel.all.pswitch + name: kernel.all.pswitch + search: + key_: kernel.all.pswitch + type: 2 + value_type: 3 + selectApplications: extend + - hostid: null + key_: kernel.uname.release + name: kernel.uname.release + search: + key_: kernel.uname.release + type: 2 + value_type: 4 + selectApplications: extend + - hostid: null + key_: proc.nprocs + name: proc.nprocs + search: + key_: proc.nprocs + type: 2 + value_type: 3 + selectApplications: extend 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 diff --git a/roles/openshift_master_certificates/tasks/main.yml b/roles/openshift_master_certificates/tasks/main.yml index 297d53bcd..bb23cf4f4 100644 --- a/roles/openshift_master_certificates/tasks/main.yml +++ b/roles/openshift_master_certificates/tasks/main.yml @@ -15,6 +15,22 @@ - - ca.crt - ca.key - ca.serial.txt + - admin.crt + - admin.key + - admin.kubeconfig + - master.kubelet-client.crt + - master.kubelet-client.key + - openshift-master.crt + - openshift-master.key + - openshift-master.kubeconfig + - openshift-registry.crt + - openshift-registry.key + - openshift-registry.kubeconfig + - openshift-router.crt + - openshift-router.key + - openshift-router.kubeconfig + - serviceaccounts.private.key + - serviceaccounts.public.key - name: Create the master certificates if they do not already exist |