diff options
author | Kenny Woodson <kwoodson@redhat.com> | 2015-08-27 11:12:42 -0400 |
---|---|---|
committer | Kenny Woodson <kwoodson@redhat.com> | 2015-08-27 11:12:42 -0400 |
commit | 91eebb77744753bde5b4b83e7c7634ee47e5b859 (patch) | |
tree | 043628b7a804ad66019129129cc0186289d80a28 | |
parent | d228350e4b9cc6b5341985940f12a50ec2847768 (diff) | |
download | openshift-91eebb77744753bde5b4b83e7c7634ee47e5b859.tar.gz openshift-91eebb77744753bde5b4b83e7c7634ee47e5b859.tar.bz2 openshift-91eebb77744753bde5b4b83e7c7634ee47e5b859.tar.xz openshift-91eebb77744753bde5b4b83e7c7634ee47e5b859.zip |
Revert "Zabbix API updates"
-rw-r--r-- | filter_plugins/oo_zabbix_filters.py | 29 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/clean_zabbix.yml | 51 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/create_template.yml | 57 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/create_user.yml | 31 | ||||
l--------- | playbooks/adhoc/zabbix_setup/filter_plugins | 1 | ||||
l--------- | playbooks/adhoc/zabbix_setup/roles | 1 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/setup_zabbix.yml | 38 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/vars/template_heartbeat.yml (renamed from roles/os_zabbix/vars/template_heartbeat.yml) | 4 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/vars/template_host.yml (renamed from roles/os_zabbix/vars/template_host.yml) | 0 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/vars/template_master.yml (renamed from roles/os_zabbix/vars/template_master.yml) | 0 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/vars/template_node.yml (renamed from roles/os_zabbix/vars/template_node.yml) | 0 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/vars/template_os_linux.yml (renamed from roles/os_zabbix/vars/template_os_linux.yml) | 53 | ||||
-rw-r--r-- | playbooks/adhoc/zabbix_setup/vars/template_router.yml (renamed from roles/os_zabbix/vars/template_router.yml) | 0 | ||||
-rw-r--r-- | roles/lib_zabbix/README.md | 38 | ||||
-rw-r--r-- | roles/lib_zabbix/library/zbx_user_media.py | 240 | ||||
-rw-r--r-- | roles/os_zabbix/README.md | 40 | ||||
-rw-r--r-- | roles/os_zabbix/defaults/main.yml | 1 | ||||
-rw-r--r-- | roles/os_zabbix/handlers/main.yml | 1 | ||||
-rw-r--r-- | roles/os_zabbix/library/__init__.py (renamed from roles/lib_zabbix/library/__init__.py) | 0 | ||||
-rw-r--r-- | roles/os_zabbix/library/get_drule.yml | 115 | ||||
-rw-r--r-- | roles/os_zabbix/library/test.yml (renamed from roles/lib_zabbix/library/test.yml) | 0 | ||||
-rw-r--r-- | roles/os_zabbix/library/zbx_application.py (renamed from roles/lib_zabbix/library/zbx_application.py) | 18 | ||||
-rw-r--r-- | roles/os_zabbix/library/zbx_discoveryrule.py (renamed from roles/lib_zabbix/library/zbx_discoveryrule.py) | 0 | ||||
-rw-r--r-- | roles/os_zabbix/library/zbx_host.py (renamed from roles/lib_zabbix/library/zbx_host.py) | 0 | ||||
-rw-r--r-- | roles/os_zabbix/library/zbx_hostgroup.py (renamed from roles/lib_zabbix/library/zbx_hostgroup.py) | 0 | ||||
-rw-r--r-- | roles/os_zabbix/library/zbx_item.py (renamed from roles/lib_zabbix/library/zbx_item.py) | 3 | ||||
-rw-r--r-- | roles/os_zabbix/library/zbx_itemprototype.py (renamed from roles/lib_zabbix/library/zbx_itemprototype.py) | 0 | ||||
-rw-r--r-- | roles/os_zabbix/library/zbx_mediatype.py (renamed from roles/lib_zabbix/library/zbx_mediatype.py) | 21 | ||||
-rw-r--r-- | roles/os_zabbix/library/zbx_template.py (renamed from roles/lib_zabbix/library/zbx_template.py) | 18 | ||||
-rw-r--r-- | roles/os_zabbix/library/zbx_trigger.py (renamed from roles/lib_zabbix/library/zbx_trigger.py) | 1 | ||||
-rw-r--r-- | roles/os_zabbix/library/zbx_user.py (renamed from roles/lib_zabbix/library/zbx_user.py) | 11 | ||||
-rw-r--r-- | roles/os_zabbix/library/zbx_usergroup.py (renamed from roles/lib_zabbix/library/zbx_usergroup.py) | 90 | ||||
-rw-r--r-- | roles/os_zabbix/meta/main.yml | 9 | ||||
-rw-r--r-- | roles/os_zabbix/tasks/clean_zabbix.yml | 47 | ||||
-rw-r--r-- | roles/os_zabbix/tasks/create_template.yml | 56 | ||||
-rw-r--r-- | roles/os_zabbix/tasks/create_user.yml | 11 | ||||
-rw-r--r-- | roles/os_zabbix/tasks/main.yml | 30 | ||||
-rw-r--r-- | roles/os_zabbix/vars/main.yml | 1 |
38 files changed, 334 insertions, 682 deletions
diff --git a/filter_plugins/oo_zabbix_filters.py b/filter_plugins/oo_zabbix_filters.py index c44b874e8..a473993a2 100644 --- a/filter_plugins/oo_zabbix_filters.py +++ b/filter_plugins/oo_zabbix_filters.py @@ -60,17 +60,6 @@ class FilterModule(object): return None @staticmethod - def oo_build_zabbix_collect(data, string, value): - ''' Build a list of dicts from a list of data matched on string attribute - ''' - rval = [] - for item in data: - if item[string] == value: - rval.append(item) - - return rval - - @staticmethod def oo_build_zabbix_list_dict(values, string): ''' Build a list of dicts with string as key for each value ''' @@ -79,22 +68,6 @@ class FilterModule(object): rval.append({string: value}) return rval - @staticmethod - def oo_remove_attr_from_list_dict(data, attr): - ''' Remove a specific attribute from a dict - ''' - attrs = [] - if isinstance(attr, str): - attrs.append(attr) - else: - attrs = attr - - for attribute in attrs: - for _entry in data: - _entry.pop(attribute, None) - - return data - def filters(self): ''' returns a mapping of filters to methods ''' return { @@ -103,6 +76,4 @@ class FilterModule(object): "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, - "oo_build_zabbix_collect": self.oo_build_zabbix_collect, - "oo_remove_attr_from_list_dict": self.oo_remove_attr_from_list_dict, } 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/roles/os_zabbix/vars/template_heartbeat.yml b/playbooks/adhoc/zabbix_setup/vars/template_heartbeat.yml index 158d6c79a..22cc75554 100644 --- a/roles/os_zabbix/vars/template_heartbeat.yml +++ b/playbooks/adhoc/zabbix_setup/vars/template_heartbeat.yml @@ -1,11 +1,9 @@ --- g_template_heartbeat: name: Template Heartbeat - zapplications: - - Heartbeat zitems: - name: Heartbeat Ping - application: Heartbeat + hostid: key: heartbeat.ping ztriggers: - description: 'Heartbeat.ping has failed on {HOST.NAME}' diff --git a/roles/os_zabbix/vars/template_host.yml b/playbooks/adhoc/zabbix_setup/vars/template_host.yml index e7cc667cb..e7cc667cb 100644 --- a/roles/os_zabbix/vars/template_host.yml +++ b/playbooks/adhoc/zabbix_setup/vars/template_host.yml diff --git a/roles/os_zabbix/vars/template_master.yml b/playbooks/adhoc/zabbix_setup/vars/template_master.yml index 5f9b41a4f..5f9b41a4f 100644 --- a/roles/os_zabbix/vars/template_master.yml +++ b/playbooks/adhoc/zabbix_setup/vars/template_master.yml diff --git a/roles/os_zabbix/vars/template_node.yml b/playbooks/adhoc/zabbix_setup/vars/template_node.yml index 98c343a24..98c343a24 100644 --- a/roles/os_zabbix/vars/template_node.yml +++ b/playbooks/adhoc/zabbix_setup/vars/template_node.yml diff --git a/roles/os_zabbix/vars/template_os_linux.yml b/playbooks/adhoc/zabbix_setup/vars/template_os_linux.yml index 1cc928bce..9cc038ffa 100644 --- a/roles/os_zabbix/vars/template_os_linux.yml +++ b/playbooks/adhoc/zabbix_setup/vars/template_os_linux.yml @@ -1,143 +1,90 @@ --- g_template_os_linux: name: Template OS Linux - zapplications: - - Disk - - Memory - - Kernel zitems: - key: kernel.uname.sysname - application: Kernel value_type: string - key: kernel.all.cpu.wait.total - application: Kernel value_type: int - key: kernel.all.cpu.irq.hard - application: Kernel value_type: int - key: kernel.all.cpu.idle - application: Kernel value_type: int - key: kernel.uname.distro - application: Kernel value_type: string - key: kernel.uname.nodename - application: Kernel value_type: string - key: kernel.all.cpu.irq.soft - application: Kernel value_type: int - key: kernel.all.load.15_minute - application: Kernel value_type: float - key: kernel.all.cpu.sys - application: Kernel value_type: int - key: kernel.all.load.5_minute - application: Kernel value_type: float - key: mem.freemem - application: Memory value_type: int - key: kernel.all.cpu.nice - application: Kernel value_type: int - key: mem.util.bufmem - application: Memory value_type: int - key: swap.used - application: Memory value_type: int - key: kernel.all.load.1_minute - application: Kernel value_type: float - key: kernel.uname.version - application: Kernel value_type: string - key: swap.length - application: Memory value_type: int - key: mem.physmem - application: Memory value_type: int - key: kernel.all.uptime - application: Kernel value_type: int - key: swap.free - application: Memory value_type: int - key: mem.util.used - application: Memory value_type: int - key: kernel.all.cpu.user - application: Kernel value_type: int - key: kernel.uname.machine - application: Kernel value_type: string - key: hinv.ncpu - application: Kernel value_type: int - key: mem.util.cached - application: Memory value_type: int - key: kernel.all.cpu.steal - application: Kernel value_type: int - key: kernel.all.pswitch - application: Kernel value_type: int - key: kernel.uname.release - application: Kernel value_type: string - key: proc.nprocs - application: Kernel value_type: int - - - key: filesys.avail - application: Disk - value_type: int - - - key: filesys.capacity - application: Disk - value_type: int - - - key: filesys.free - application: Disk - value_type: int - - - key: filesys.full - application: Disk - value_type: float - - - key: filesys.used - application: Disk - value_type: float diff --git a/roles/os_zabbix/vars/template_router.yml b/playbooks/adhoc/zabbix_setup/vars/template_router.yml index 4dae7da1e..4dae7da1e 100644 --- a/roles/os_zabbix/vars/template_router.yml +++ b/playbooks/adhoc/zabbix_setup/vars/template_router.yml diff --git a/roles/lib_zabbix/README.md b/roles/lib_zabbix/README.md deleted file mode 100644 index 69debc698..000000000 --- a/roles/lib_zabbix/README.md +++ /dev/null @@ -1,38 +0,0 @@ -zabbix -========= - -Automate zabbix tasks. - -Requirements ------------- - -This requires the openshift_tools rpm be installed for the zbxapi.py library. It can be found here: https://github.com/openshift/openshift-tools under openshift_tools/monitoring/zbxapi.py for now. - -Role Variables --------------- - -None - -Dependencies ------------- - -This depeonds on the zbxapi.py library located here: https://github.com/openshift/openshift-tools under openshift_tools/monitoring/zbxapi.py for now. - -Example Playbook ----------------- - - - zbx_host: - server: zab_server - user: zab_user - password: zab_password - name: 'myhost' - -License -------- - -ASL 2.0 - -Author Information ------------------- - -OpenShift operations, Red Hat, Inc diff --git a/roles/lib_zabbix/library/zbx_user_media.py b/roles/lib_zabbix/library/zbx_user_media.py deleted file mode 100644 index f590c58fe..000000000 --- a/roles/lib_zabbix/library/zbx_user_media.py +++ /dev/null @@ -1,240 +0,0 @@ -#!/usr/bin/env python -''' - Ansible module for user media -''' -# vim: expandtab:tabstop=4:shiftwidth=4 -# -# Zabbix user media ansible module -# -# -# Copyright 2015 Red Hat Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# This is in place because each module looks similar to each other. -# These need duplicate code as their behavior is very similar -# but different for each zabbix class. -# pylint: disable=duplicate-code - -# pylint: disable=import-error -from openshift_tools.monitoring.zbxapi import ZabbixAPI, ZabbixConnection - -def exists(content, key='result'): - ''' Check if key exists in content or the size of content[key] > 0 - ''' - if not content.has_key(key): - return False - - if not content[key]: - return False - - return True - -def get_mtype(zapi, mtype): - '''Get mediatype - - If passed an int, return it as the mediatypeid - if its a string, then try to fetch through a description - ''' - if isinstance(mtype, int): - return mtype - try: - return int(mtype) - except ValueError: - pass - - content = zapi.get_content('mediatype', 'get', {'search': {'description': mtype}}) - if content.has_key['result'] and content['result']: - return content['result'][0]['mediatypeid'] - - return None - -def get_user(zapi, user): - ''' Get userids from user aliases - ''' - content = zapi.get_content('user', 'get', {'search': {'alias': user}}) - if content['result']: - return content['result'][0] - - return None - -def get_severity(severity): - ''' determine severity - ''' - if isinstance(severity, int) or \ - isinstance(severity, str): - return severity - - val = 0 - sev_map = { - 'not': 2**0, - 'inf': 2**1, - 'war': 2**2, - 'ave': 2**3, - 'avg': 2**3, - 'hig': 2**4, - 'dis': 2**5, - } - for level in severity: - val |= sev_map[level[:3].lower()] - return val - -def get_zbx_user_query_data(zapi, user_name): - ''' If name exists, retrieve it, and build query params. - ''' - query = {} - if user_name: - zbx_user = get_user(zapi, user_name) - query = {'userids': zbx_user['userid']} - - return query - -def find_media(medias, user_media): - ''' Find the user media in the list of medias - ''' - for media in medias: - if all([media[key] == user_media[key] for key in user_media.keys()]): - return media - return None - -def get_active(in_active): - '''Determine active value - ''' - active = 1 - if in_active: - active = 0 - - return active - -def main(): - ''' - Ansible zabbix module for mediatype - ''' - - module = AnsibleModule( - argument_spec=dict( - server=dict(default='https://localhost/zabbix/api_jsonrpc.php', type='str'), - user=dict(default=None, type='str'), - password=dict(default=None, type='str'), - name=dict(default=None, type='str'), - active=dict(default=False, type='bool'), - medias=dict(default=None, type='list'), - mediaid=dict(default=None, type='int'), - mediatype=dict(default=None, type='str'), - mediatype_desc=dict(default=None, type='str'), - #d-d,hh:mm-hh:mm;d-d,hh:mm-hh:mm... - period=dict(default=None, type='str'), - sendto=dict(default=None, type='str'), - severity=dict(default=None, type='str'), - debug=dict(default=False, type='bool'), - state=dict(default='present', type='str'), - ), - #supports_check_mode=True - ) - - user = module.params.get('user', os.environ['ZABBIX_USER']) - passwd = module.params.get('password', os.environ['ZABBIX_PASSWORD']) - - zapi = ZabbixAPI(ZabbixConnection(module.params['server'], user, passwd, module.params['debug'])) - - #Set the instance and the template for the rest of the calls - zbx_class_name = 'user' - idname = "mediaid" - state = module.params['state'] - - # User media is fetched through the usermedia.get - zbx_user_query = get_zbx_user_query_data(zapi, module.params['name']) - content = zapi.get_content('usermedia', 'get', zbx_user_query) - - if state == 'list': - module.exit_json(changed=False, results=content['result'], state="list") - - if state == 'absent': - if not exists(content) or len(content['result']) == 0: - module.exit_json(changed=False, state="absent") - - # TODO: Do we remove all the queried results? This could be catastrophic or desired. - #ids = [med[idname] for med in content['result']] - ids = [content['result'][0][idname]] - content = zapi.get_content(zbx_class_name, 'deletemedia', ids) - - if content.has_key('error'): - module.exit_json(changed=False, results=content['error'], state="absent") - - module.exit_json(changed=True, results=content['result'], state="absent") - - if state == 'present': - active = get_active(module.params['active']) - mtypeid = None - if module.params['mediatype']: - mtypeid = get_mtype(zapi, module.params['mediatype']) - elif module.params['mediatype_desc']: - mtypeid = get_mtype(zapi, module.params['mediatype_desc']) - - medias = module.params['medias'] - if medias == None: - medias = [{'mediatypeid': mtypeid, - 'sendto': module.params['sendto'], - 'active': active, - 'severity': int(get_severity(module.params['severity'])), - 'period': module.params['period'], - }] - - params = {'users': [zbx_user_query], - 'medias': medias, - 'output': 'extend', - } - if not exists(content): - # if we didn't find it, create it - content = zapi.get_content(zbx_class_name, 'addmedia', params) - - if content.has_key('error'): - module.exit_json(failed=True, changed=False, results=content['error'], state="present") - - module.exit_json(changed=True, results=content['result'], state='present') - - # mediaid signifies an update - # If user params exists, check to see if they already exist in zabbix - # if they exist, then return as no update - # elif they do not exist, then take user params only - differences = {'medias': [], 'users': {}} - for media in params['medias']: - m_result = find_media(content['result'], media) - if not m_result: - differences['medias'].append(media) - - if not differences['medias']: - module.exit_json(changed=False, results=content['result'], state="present") - - for user in params['users']: - differences['users']['userid'] = user['userids'] - - # We have differences and need to update - content = zapi.get_content(zbx_class_name, 'updatemedia', differences) - - if content.has_key('error'): - module.exit_json(failed=True, changed=False, results=content['error'], state="present") - - module.exit_json(changed=True, results=content['result'], state="present") - - module.exit_json(failed=True, - changed=False, - results='Unknown state passed. %s' % state, - state="unknown") - -# pylint: disable=redefined-builtin, unused-wildcard-import, wildcard-import, locally-disabled -# import module snippets. This are required -from ansible.module_utils.basic import * - -main() diff --git a/roles/os_zabbix/README.md b/roles/os_zabbix/README.md deleted file mode 100644 index ac3dc2833..000000000 --- a/roles/os_zabbix/README.md +++ /dev/null @@ -1,40 +0,0 @@ -os_zabbix -========= - -Automate zabbix tasks. - -Requirements ------------- - -This requires the openshift_tools rpm be installed for the zbxapi.py library. It can be found here: https://github.com/openshift/openshift-tools under openshift_tools/monitoring/zbxapi.py for now. - -Role Variables --------------- - -zab_server -zab_username -zab_password - -Dependencies ------------- - -This depeonds on the zbxapi.py library located here: https://github.com/openshift/openshift-tools under openshift_tools/monitoring/zbxapi.py for now. - -Example Playbook ----------------- - - - zbx_host: - server: zab_server - user: zab_user - password: zab_password - name: 'myhost' - -License -------- - -ASL 2.0 - -Author Information ------------------- - -OpenShift operations, Red Hat, Inc diff --git a/roles/os_zabbix/defaults/main.yml b/roles/os_zabbix/defaults/main.yml deleted file mode 100644 index ed97d539c..000000000 --- a/roles/os_zabbix/defaults/main.yml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/roles/os_zabbix/handlers/main.yml b/roles/os_zabbix/handlers/main.yml deleted file mode 100644 index ed97d539c..000000000 --- a/roles/os_zabbix/handlers/main.yml +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/roles/lib_zabbix/library/__init__.py b/roles/os_zabbix/library/__init__.py index e69de29bb..e69de29bb 100644 --- a/roles/lib_zabbix/library/__init__.py +++ b/roles/os_zabbix/library/__init__.py diff --git a/roles/os_zabbix/library/get_drule.yml b/roles/os_zabbix/library/get_drule.yml new file mode 100644 index 000000000..a3e39f535 --- /dev/null +++ b/roles/os_zabbix/library/get_drule.yml @@ -0,0 +1,115 @@ +--- +# This is a test playbook to create one of each of the zabbix ansible modules. +# ensure that the zbxapi module is installed +# ansible-playbook test.yml +- name: Test zabbix ansible module + hosts: localhost + gather_facts: no + vars: +#zbx_server: https://localhost/zabbix/api_jsonrpc.php +#zbx_user: Admin +#zbx_password: zabbix + + pre_tasks: + - name: Template Discovery rules + zbx_template: + server: "{{ zbx_server }}" + user: "{{ zbx_user }}" + password: "{{ zbx_password }}" + name: 'Template App HaProxy' + state: list + register: template_output + + - debug: var=template_output + + - name: Discovery rules + zbx_discovery_rule: + server: "{{ zbx_server }}" + user: "{{ zbx_user }}" + password: "{{ zbx_password }}" + name: 'haproxy.discovery sender' + state: list + register: drule + + - debug: var=drule + +# - name: Create an application +# zbx_application: +# server: "{{ zbx_server }}" +# user: "{{ zbx_user }}" +# password: "{{ zbx_password }}" +# name: 'Test App' +# template_name: "test template" +# register: item_output +# +# - name: Create an item +# zbx_item: +# server: "{{ zbx_server }}" +# user: "{{ zbx_user }}" +# password: "{{ zbx_password }}" +# name: 'test item' +# key: 'kenny.item.1' +# applications: +# - 'Test App' +# template_name: "test template" +# register: item_output +# +# - debug: var=item_output +# +# - name: Create an trigger +# zbx_trigger: +# server: "{{ zbx_server }}" +# user: "{{ zbx_user }}" +# password: "{{ zbx_password }}" +# expression: '{test template:kenny.item.1.last()}>2' +# description: 'Kenny desc' +# register: trigger_output +# +# - debug: var=trigger_output +# +# - name: Create a hostgroup +# zbx_hostgroup: +# server: "{{ zbx_server }}" +# user: "{{ zbx_user }}" +# password: "{{ zbx_password }}" +# name: 'kenny hostgroup' +# register: hostgroup_output +# +# - debug: var=hostgroup_output +# +# - name: Create a host +# zbx_host: +# server: "{{ zbx_server }}" +# user: "{{ zbx_user }}" +# password: "{{ zbx_password }}" +# name: 'kenny host' +# template_names: +# - test template +# hostgroup_names: +# - kenny hostgroup +# register: host_output +# +# - debug: var=host_output +# +# - name: Create a usergroup +# zbx_usergroup: +# server: "{{ zbx_server }}" +# user: "{{ zbx_user }}" +# password: "{{ zbx_password }}" +# name: kenny usergroup +# rights: +# - 'kenny hostgroup': rw +# register: usergroup_output +# +# - debug: var=usergroup_output +# +# - name: Create a user +# zbx_user: +# server: "{{ zbx_server }}" +# user: "{{ zbx_user }}" +# password: "{{ zbx_password }}" +# alias: kwoodson +# state: list +# register: user_output +# +# - debug: var=user_output diff --git a/roles/lib_zabbix/library/test.yml b/roles/os_zabbix/library/test.yml index cedace1a0..cedace1a0 100644 --- a/roles/lib_zabbix/library/test.yml +++ b/roles/os_zabbix/library/test.yml diff --git a/roles/lib_zabbix/library/zbx_application.py b/roles/os_zabbix/library/zbx_application.py index 01df1a98e..5d4acf72d 100644 --- a/roles/lib_zabbix/library/zbx_application.py +++ b/roles/os_zabbix/library/zbx_application.py @@ -60,8 +60,8 @@ def main(): module = AnsibleModule( argument_spec=dict( server=dict(default='https://localhost/zabbix/api_jsonrpc.php', type='str'), - user=dict(default=os.environ['ZABBIX_USER'], type='str'), - password=dict(default=os.environ['ZABBIX_PASSWORD'], type='str'), + user=dict(default=None, type='str'), + password=dict(default=None, type='str'), name=dict(default=None, type='str'), template_name=dict(default=None, type='list'), debug=dict(default=False, type='bool'), @@ -70,10 +70,10 @@ def main(): #supports_check_mode=True ) - zapi = ZabbixAPI(ZabbixConnection(module.params['server'], - module.params['user'], - module.params['password'], - module.params['debug'])) + user = module.params.get('user', os.environ['ZABBIX_USER']) + passwd = module.params.get('password', os.environ['ZABBIX_PASSWORD']) + + zapi = ZabbixAPI(ZabbixConnection(module.params['server'], user, passwd, module.params['debug'])) #Set the instance and the application for the rest of the calls zbx_class_name = 'application' @@ -83,7 +83,7 @@ def main(): # get a applicationid, see if it exists content = zapi.get_content(zbx_class_name, 'get', - {'search': {'name': aname}, + {'search': {'host': aname}, 'selectHost': 'hostid', }) if state == 'list': @@ -121,10 +121,6 @@ def main(): # We have differences and need to update differences[idname] = zab_results[idname] content = zapi.get_content(zbx_class_name, 'update', differences) - - if content.has_key('error'): - module.exit_json(failed=True, changed=False, results=content['error'], state="present") - module.exit_json(changed=True, results=content['result'], state="present") module.exit_json(failed=True, diff --git a/roles/lib_zabbix/library/zbx_discoveryrule.py b/roles/os_zabbix/library/zbx_discoveryrule.py index 56b87fecc..56b87fecc 100644 --- a/roles/lib_zabbix/library/zbx_discoveryrule.py +++ b/roles/os_zabbix/library/zbx_discoveryrule.py diff --git a/roles/lib_zabbix/library/zbx_host.py b/roles/os_zabbix/library/zbx_host.py index 12c5f3456..12c5f3456 100644 --- a/roles/lib_zabbix/library/zbx_host.py +++ b/roles/os_zabbix/library/zbx_host.py diff --git a/roles/lib_zabbix/library/zbx_hostgroup.py b/roles/os_zabbix/library/zbx_hostgroup.py index a1eb875d4..a1eb875d4 100644 --- a/roles/lib_zabbix/library/zbx_hostgroup.py +++ b/roles/os_zabbix/library/zbx_hostgroup.py diff --git a/roles/lib_zabbix/library/zbx_item.py b/roles/os_zabbix/library/zbx_item.py index 64dbb976f..45ba6c2b0 100644 --- a/roles/lib_zabbix/library/zbx_item.py +++ b/roles/os_zabbix/library/zbx_item.py @@ -63,8 +63,6 @@ def get_value_type(value_type): def get_app_ids(zapi, application_names): ''' get application ids from names ''' - if isinstance(application_names, str): - application_names = [application_names] app_ids = [] for app_name in application_names: content = zapi.get_content('application', 'get', {'search': {'name': app_name}}) @@ -120,7 +118,6 @@ def main(): {'search': {'key_': key}, 'selectApplications': 'applicationid', }) - if state == 'list': module.exit_json(changed=False, results=content['result'], state="list") diff --git a/roles/lib_zabbix/library/zbx_itemprototype.py b/roles/os_zabbix/library/zbx_itemprototype.py index f0eb6bbbd..f0eb6bbbd 100644 --- a/roles/lib_zabbix/library/zbx_itemprototype.py +++ b/roles/os_zabbix/library/zbx_itemprototype.py diff --git a/roles/lib_zabbix/library/zbx_mediatype.py b/roles/os_zabbix/library/zbx_mediatype.py index b8dcaf7aa..a49aecd0f 100644 --- a/roles/lib_zabbix/library/zbx_mediatype.py +++ b/roles/os_zabbix/library/zbx_mediatype.py @@ -40,7 +40,6 @@ def exists(content, key='result'): return False return True - def get_mtype(mtype): ''' Transport used by the media type. @@ -81,10 +80,6 @@ def main(): smtp_server=dict(default=None, type='str'), smtp_helo=dict(default=None, type='str'), smtp_email=dict(default=None, type='str'), - passwd=dict(default=None, type='str'), - path=dict(default=None, type='str'), - username=dict(default=None, type='str'), - status=dict(default='enabled', type='str'), debug=dict(default=False, type='bool'), state=dict(default='present', type='str'), ), @@ -114,30 +109,16 @@ def main(): module.exit_json(changed=True, results=content['result'], state="absent") if state == 'present': - status = 1 - if module.params['status']: - status = 0 params = {'description': description, - 'type': get_mtype(module.params['mtype']), + 'type': get_mtype(module.params['media_type']), 'smtp_server': module.params['smtp_server'], 'smtp_helo': module.params['smtp_helo'], 'smtp_email': module.params['smtp_email'], - 'passwd': module.params['passwd'], - 'exec_path': module.params['path'], - 'username': module.params['username'], - 'status': status, } - # Remove any None valued params - _ = [params.pop(key, None) for key in params.keys() if params[key] is None] - if not exists(content): # if we didn't find it, create it content = zapi.get_content(zbx_class_name, 'create', params) - - if content.has_key('error'): - module.exit_json(failed=True, changed=False, results=content['error'], state="present") - module.exit_json(changed=True, results=content['result'], state='present') # already exists, we need to update it # let's compare properties diff --git a/roles/lib_zabbix/library/zbx_template.py b/roles/os_zabbix/library/zbx_template.py index f86f22003..20ea48a85 100644 --- a/roles/lib_zabbix/library/zbx_template.py +++ b/roles/os_zabbix/library/zbx_template.py @@ -48,8 +48,8 @@ def main(): module = AnsibleModule( argument_spec=dict( server=dict(default='https://localhost/zabbix/api_jsonrpc.php', type='str'), - user=dict(default=os.environ['ZABBIX_USER'], type='str'), - password=dict(default=os.environ['ZABBIX_PASSWORD'], type='str'), + user=dict(default=None, type='str'), + password=dict(default=None, type='str'), name=dict(default=None, type='str'), debug=dict(default=False, type='bool'), state=dict(default='present', type='str'), @@ -57,10 +57,10 @@ def main(): #supports_check_mode=True ) - zbc = ZabbixConnection(module.params['server'], - module.params['user'], - module.params['password'], - module.params['debug']) + user = module.params.get('user', os.environ['ZABBIX_USER']) + passwd = module.params.get('password', os.environ['ZABBIX_PASSWORD']) + + zbc = ZabbixConnection(module.params['server'], user, passwd, module.params['debug']) zapi = ZabbixAPI(zbc) #Set the instance and the template for the rest of the calls @@ -84,12 +84,6 @@ def main(): if not exists(content): module.exit_json(changed=False, state="absent") - if not tname: - module.exit_json(failed=True, - changed=False, - results='Must specifiy a template name.', - state="absent") - content = zapi.get_content(zbx_class_name, 'delete', [content['result'][0][idname]]) module.exit_json(changed=True, results=content['result'], state="absent") diff --git a/roles/lib_zabbix/library/zbx_trigger.py b/roles/os_zabbix/library/zbx_trigger.py index 6f5392437..7cc9356c8 100644 --- a/roles/lib_zabbix/library/zbx_trigger.py +++ b/roles/os_zabbix/library/zbx_trigger.py @@ -41,6 +41,7 @@ def exists(content, key='result'): return True + def get_priority(priority): ''' determine priority ''' diff --git a/roles/lib_zabbix/library/zbx_user.py b/roles/os_zabbix/library/zbx_user.py index 220caa6f1..c45c9a75d 100644 --- a/roles/lib_zabbix/library/zbx_user.py +++ b/roles/os_zabbix/library/zbx_user.py @@ -88,7 +88,7 @@ def main(): surname=dict(default=None, type='str'), user_type=dict(default=None, type='str'), passwd=dict(default=None, type='str'), - user_groups=dict(default=[], type='list'), + usergroups=dict(default=[], type='list'), debug=dict(default=False, type='bool'), state=dict(default='present', type='str'), ), @@ -116,7 +116,7 @@ def main(): module.exit_json(changed=False, results=content['result'], state="list") if state == 'absent': - if not exists(content) or len(content['result']) == 0: + if not exists(content): module.exit_json(changed=False, state="absent") content = zapi.get_content(zbx_class_name, 'delete', [content['result'][0][idname]]) @@ -125,7 +125,7 @@ def main(): if state == 'present': params = {'alias': alias, 'passwd': module.params['passwd'], - 'usrgrps': get_usergroups(zapi, module.params['user_groups']), + 'usrgrps': get_usergroups(zapi, module.params['usergroups']), 'name': module.params['name'], 'surname': module.params['surname'], 'type': get_usertype(module.params['user_type']), @@ -146,11 +146,6 @@ def main(): if key == 'passwd': differences[key] = value - elif key == 'usrgrps': - # this must be done as a list of ordered dictionaries fails comparison - if not all([True for _ in zab_results[key][0] if _ in value[0]]): - differences[key] = value - elif zab_results[key] != value and zab_results[key] != str(value): differences[key] = value diff --git a/roles/lib_zabbix/library/zbx_usergroup.py b/roles/os_zabbix/library/zbx_usergroup.py index 11aef106c..ede4c9df1 100644 --- a/roles/lib_zabbix/library/zbx_usergroup.py +++ b/roles/os_zabbix/library/zbx_usergroup.py @@ -44,9 +44,6 @@ def exists(content, key='result'): def get_rights(zapi, rights): '''Get rights ''' - if rights == None: - return None - perms = [] for right in rights: hstgrp = right.keys()[0] @@ -62,49 +59,16 @@ def get_rights(zapi, rights): 'permission': permission}) return perms -def get_gui_access(access): - ''' Return the gui_access for a usergroup - ''' - access = access.lower() - if access == 'internal': - return 1 - elif access == 'disabled': - return 2 - - return 0 - -def get_debug_mode(mode): - ''' Return the debug_mode for a usergroup +def get_userids(zapi, users): + ''' Get userids from user aliases ''' - mode = mode.lower() - if mode == 'enabled': - return 1 - - return 0 - -def get_user_status(status): - ''' Return the user_status for a usergroup - ''' - status = status.lower() - if status == 'enabled': - return 0 - - return 1 - + userids = [] + for alias in users: + content = zapi.get_content('user', 'get', {'search': {'alias': alias}}) + if content['result']: + userids.append(content['result'][0]['userid']) -#def get_userids(zapi, users): -# ''' Get userids from user aliases -# ''' -# if not users: -# return None -# -# userids = [] -# for alias in users: -# content = zapi.get_content('user', 'get', {'search': {'alias': alias}}) -# if content['result']: -# userids.append(content['result'][0]['userid']) -# -# return userids + return userids def main(): ''' Ansible module for usergroup @@ -115,24 +79,21 @@ def main(): module = AnsibleModule( argument_spec=dict( server=dict(default='https://localhost/zabbix/api_jsonrpc.php', type='str'), - user=dict(default=os.environ.get('ZABBIX_USER', None), type='str'), - password=dict(default=os.environ.get('ZABBIX_PASSWORD', None), type='str'), - debug_mode=dict(default='disabled', type='str'), - gui_access=dict(default='default', type='str'), - status=dict(default='enabled', type='str'), - name=dict(default=None, type='str', required=True), - rights=dict(default=None, type='list'), - #users=dict(default=None, type='list'), + user=dict(default=None, type='str'), + password=dict(default=None, type='str'), + name=dict(default=None, type='str'), + rights=dict(default=[], type='list'), + users=dict(default=[], type='list'), debug=dict(default=False, type='bool'), state=dict(default='present', type='str'), ), #supports_check_mode=True ) - zapi = ZabbixAPI(ZabbixConnection(module.params['server'], - module.params['user'], - module.params['password'], - module.params['debug'])) + user = module.params.get('user', os.environ['ZABBIX_USER']) + passwd = module.params.get('password', os.environ['ZABBIX_PASSWORD']) + + zapi = ZabbixAPI(ZabbixConnection(module.params['server'], user, passwd, module.params['debug'])) zbx_class_name = 'usergroup' idname = "usrgrpid" @@ -151,24 +112,15 @@ def main(): if not exists(content): module.exit_json(changed=False, state="absent") - if not uname: - module.exit_json(failed=True, changed=False, results='Need to pass in a user.', state="error") - content = zapi.get_content(zbx_class_name, 'delete', [content['result'][0][idname]]) module.exit_json(changed=True, results=content['result'], state="absent") if state == 'present': - params = {'name': uname, 'rights': get_rights(zapi, module.params['rights']), - 'users_status': get_user_status(module.params['status']), - 'gui_access': get_gui_access(module.params['gui_access']), - 'debug_mode': get_debug_mode(module.params['debug_mode']), - #'userids': get_userids(zapi, module.params['users']), + 'userids': get_userids(zapi, module.params['users']), } - _ = [params.pop(key, None) for key in params.keys() if params[key] == None] - if not exists(content): # if we didn't find it, create it content = zapi.get_content(zbx_class_name, 'create', params) @@ -181,9 +133,9 @@ def main(): if key == 'rights': differences['rights'] = value - #elif key == 'userids' and zab_results.has_key('users'): - #if zab_results['users'] != value: - #differences['userids'] = value + elif key == 'userids' and zab_results.has_key('users'): + if zab_results['users'] != value: + differences['userids'] = value elif zab_results[key] != value and zab_results[key] != str(value): differences[key] = value diff --git a/roles/os_zabbix/meta/main.yml b/roles/os_zabbix/meta/main.yml deleted file mode 100644 index 360f5aad2..000000000 --- a/roles/os_zabbix/meta/main.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -galaxy_info: - author: OpenShift - description: ZabbixAPI - company: Red Hat, Inc - license: ASL 2.0 - min_ansible_version: 1.2 -dependencies: -- lib_zabbix diff --git a/roles/os_zabbix/tasks/clean_zabbix.yml b/roles/os_zabbix/tasks/clean_zabbix.yml deleted file mode 100644 index 1bcc07d42..000000000 --- a/roles/os_zabbix/tasks/clean_zabbix.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -- 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 deleted file mode 100644 index 070390aba..000000000 --- a/roles/os_zabbix/tasks/create_template.yml +++ /dev/null @@ -1,56 +0,0 @@ ---- -- 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 deleted file mode 100644 index 1f752a9e1..000000000 --- a/roles/os_zabbix/tasks/create_user.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -- 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 deleted file mode 100644 index 06c0a09fc..000000000 --- a/roles/os_zabbix/tasks/main.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -- 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 }}" - diff --git a/roles/os_zabbix/vars/main.yml b/roles/os_zabbix/vars/main.yml deleted file mode 100644 index ed97d539c..000000000 --- a/roles/os_zabbix/vars/main.yml +++ /dev/null @@ -1 +0,0 @@ ---- |