GithubHelp home page GithubHelp logo

dj-wasabi / ansible-zabbix-agent Goto Github PK

View Code? Open in Web Editor NEW
328.0 328.0 251.0 532 KB

Installing and maintaining zabbix-agent for RedHat/Debian/Ubuntu/Windows/Suse.

Home Page: https://galaxy.ansible.com/dj-wasabi/zabbix-agent

License: MIT License

Python 100.00%

ansible-zabbix-agent's Introduction

Hi there ๐Ÿ‘‹

I am a nerd and likes to automate things to make my life easier. Mostly specific to Ansible, Zabbix and Kubernetes, but there are a lot of interesting technologies out there!

If you like my work and/or need some help, please take a look at my sponsor page, Patreon or buy me a coffee.

Anurag's github stats

Zabbix
Ansible coummunity.zabbix zabbix-agent zabbix-server zabbix-proxy zabbix-web zabbix-javagateway
Puppet voxpopuli-zabbix
Kubernetes/HELM helm-zabbix
Ossec Personal
Ansible ossec-server ossec-agent dj-wasabi-release pre-commit-hooks

ansible-zabbix-agent's People

Contributors

and-win avatar asosso avatar average-joe avatar borener avatar chibacityblues avatar crazikpl avatar darco1991 avatar ddyugaev avatar dj-wasabi avatar dlbewley avatar gati0 avatar gunnarbeutner avatar hnknta avatar jdecombe-tm avatar kmonticolo avatar lingfish avatar maelstrom96 avatar mgornikov avatar neneko-kun avatar pimooss avatar rnsc avatar rolfvreijdenberger avatar rubentsirunyan avatar samyscoub avatar santiagomr avatar sblaisot avatar tobiasehlert avatar victorjerlin avatar vinclame avatar washeck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-zabbix-agent's Issues

Incorrect method "hostgroup.exists".

I faced issue, when try to create hosts and add them to Zabbix server.

Error:

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: zabbix_api.ZabbixAPIException: (u'Error -32602: Invalid params., Incorrect method "hostgroup.exists". while sending {"params": {"name": "Dev Group"}, "jsonrpc": "2.0", "method": "hostgroup.exists", "auth": "f4de56b26a4c322b22f392fb5c6b69f0", "id": 2}', -32602)
fatal: [xx.xxx.xxx.xxx -> localhost]: FAILED! => {"changed": false, "failed": true, "parsed": false}

Playbook:

  • hosts: dev
    roles:
    - role: dj-wasabi.zabbix-agent
    agent_server: yyy.yyy.yyy.yyy
    zabbix_version: 3.0
    zabbix_url: http://dev.domain.com
    zabbix_api_create_hosts: true
    zabbix_api_user: dev
    zabbix_api_pass: XXxxXX
    zabbix_create_host: present
    zabbix_host_groups:
    - "{{ ZABBIX_HOST_GROUP }}"
    zabbix_link_templates:
    - Dev Template

ListenIP should be left undefined by default and use zabbix-agent default.

If not defined in zabbix-agentd.conf then the ListenIP defaults to 0.0.0.0 (all interfaces). This should be the default.

ListenIP should not be set UNLESS the playbook user defines a agent_listeninterface.

Instead the template attempts to insert an IP address from the ansible inventory in this field. The IP is referenced like this

{% if agent_listeninterface is defined and agent_listeninterface %}
ListenIP={{ hostvars[inventory_hostname]['ansible_'+ agent_listeninterface]['ipv4'].address }}
{% endif %}

The agent_listeninterface defaults to eth0 so that evals to {{ hostvars[inventory_hostname][ansible_eth0]['ipv4'].address }} by default.

If your machine has no eth0 then the playbook fails. This forces you to override a default variable to enter a non-default entry in the config file.

There's an attempt to avoid this problem with the if statement in the template, but that fails because the inner variable is interpolated first. Which fails and bombs the playbook.

unsupported parameter for module: host_groups

Strangely enough but task Create hostgroups fails on me with:

failed: [gg-tool24 -> 127.0.0.1] => {"failed": true}
msg: unsupported parameter for module: host_groups

FATAL: all hosts have already failed -- aborting

installed from galaxy
ansible-galaxy install dj-wasabi.zabbix-agent -p roles/

with vars like those:

# Zabbix API stuff
zabbix_api_use: True
zabbix_url: http://myzabbix-host/zabbix
zabbix_api_user: myuser
zabbix_api_pass: mypassword
zabbix_create_host: true
zabbix_host_groups:
  - Linux servers

$ dpkg -l | grep zabbix | awk '{print $2 " "$3}'
zabbix-agent 1:2.0.4+dfsg-1~exp0
zabbix-frontend-php 1:2.0.4+dfsg-1~exp0
zabbix-server-mysql 1:2.0.4+dfsg-1~exp0

zabbix 3 JMX interface

Hi !

It is possible to setup JMX interface with this ansible role ?

Thanks in advance

Adding templates

Is it possible to link additional template without removing those already linked? Script seems to be just overwriting existing values. I'm trying to add different templates like apache,mysql based on services that are existing on host and it clears previously added templates linking just the one provided.

SSL: CERTIFICATE_VERIFY_FAILED

I have a valid certificate provided by godaddy but I got this error:

fatal: [10.168.3.101 -> localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Failed to connect to Zabbix server: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)>"}

Is there an option to set no_verify option?

s/agent_interfaces/zabbix_agent_interfaces ?

Hello,
Since version 1.0 all vars should start from "zabbix_". I see that in this line there is agent_interfaces without zabbix_ prefix. Is this ok?
It won't work for now:

interfaces: "{{ agent_interfaces }}"

agent_interfaces: - type: 1 main: 1 useip: "{{ zabbix_useuip }}" ip: "{{ agent_ip }}" dns: "{{ ansible_fqdn }}" port: "{{ agent_listenport }}"

An error:

fatal: [10.59.146.63]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'agent_interfaces' is undefined\n\nThe error appears to have been in '/etc/ansible/roles/dj-wasabi.zabbix-agent/tasks/main.yml': line 173, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: "Create a new host or update an existing host's info"\n ^ here\n"}

Zabbix 3.0 API change

There is a deprecated zabbix api function call in the zabbix-group.py code. Ansible module doesn't work with Zabbix 3.0 server. hostgroup.exists call must be droped according to ZBXNEXT-2724.

Can't auto create hosts

Hi,

First of all thanks for your great role!

I'm having some problems with automatically creating the host for Zabbix, here's my config:

ansible-zabbix-agent:
agent_allowroot: 0
agent_buffersend: 5
agent_buffersize: 100
agent_debuglevel: 3
agent_enableremotecommands: 1
agent_hostnameitem: system.run[hostname -f]
agent_include: /etc/zabbix/zabbix_agentd.d
agent_listenip: 0.0.0.0
agent_listenport: 10050
agent_logfilesize: 1
agent_logremotecommands: 0
agent_maxlinespersecond: 100
agent_pidfile: /var/run/zabbix/zabbix_agentd.pid
agent_refreshactivechecks: 120
agent_server: myzabbixserver
agent_serveractive: myzabbixserver
agent_startagents: 3
agent_timeout: 3
agent_unsafeuserparameters: 0
zabbix_api_create_hosts: True
zabbix_create_host: present
zabbix_url: "https://myweburl"
zabbix_api_user: my_user
zabbix_api_pass: my_pwd
zabbix_host_groups:
- Linux Servers
zabbix_link_templates:
- Template OS Linux

I'm getting only "skipped" on the step for creating the host:

TASK [ansible-zabbix-agent : Create a new host or update an existing host's info] ***
task path: /Users/nkl/dev/knip/ansible/roles/ansible-zabbix-agent/tasks/main.yml:114
skipping: [10.100.0.155] => {"changed": false, "skip_reason": "Conditional check failed", "skipped": true}

Also, I have installed zabbix-api through pip on both my local machine where I am running ansible from and the client machine.

What am I doing wrong?

EDIT: I'm using the latest version, 0.8.0. Client system is Debian 8 x64.

Error in: Create directory for PSK file if not exist

Running the new version 1.0.0 I get the following error:

task path: /etc/ansible/roles/dj-wasabi.zabbix-agent/tasks/main.yml:115
The full traceback is:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 125, in run
    res = self._execute()
  File "/usr/lib/python2.7/dist-packages/ansible/executor/task_executor.py", line 462, in _execute
    self._task.post_validate(templar=templar)
  File "/usr/lib/python2.7/dist-packages/ansible/playbook/task.py", line 247, in post_validate
    super(Task, self).post_validate(templar)
  File "/usr/lib/python2.7/dist-packages/ansible/playbook/base.py", line 373, in post_validate
    value = templar.template(getattr(self, name))
  File "/usr/lib/python2.7/dist-packages/ansible/template/__init__.py", line 481, in template
    disable_lookups=disable_lookups,
  File "/usr/lib/python2.7/dist-packages/ansible/template/__init__.py", line 437, in template
    disable_lookups=disable_lookups,
  File "/usr/lib/python2.7/dist-packages/ansible/template/__init__.py", line 659, in do_template
    res = j2_concat(rf)
  File "<template>", line 9, in root
  File "/usr/lib/python2.7/dist-packages/ansible/utils/unicode.py", line 66, in unicode_wrap
    return to_text(func(*args, **kwargs), nonstring='passthru')
  File "/usr/lib/python2.7/posixpath.py", line 122, in dirname
    i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'
fatal: [docker3]: FAILED! => {
    "failed": true, 
    "msg": "Unexpected failure during module execution.", 
    "stdout": ""
}

My ansible playbook looks like this:

- name: install zabbix agent
  hosts: all

  become: true
  become_user: root

  # see https://github.com/dj-wasabi/ansible-zabbix-agent

  roles:
    - role: dj-wasabi.zabbix-agent
      when: not (ansible_distribution == 'Ubuntu' and ansible_distribution_version == '12.04')
      zabbix_agent_server: "{{ zabbix_agent_server_dstk }}"
      zabbix_agent_serveractive: "{{ zabbix_agent_serveractive_dstk }}"
      zabbix_agent_timeout: 12
      zabbix_agent_enableremotecommands: 1
      zabbix_agent_logremotecommands: 1
      zabbix_version: 3.2
      # LogType can't be set here so syslog geht nicht. see https://www.zabbix.com/documentation/3.4/manual/appendix/config/zabbix_agentd
      # agent_logfile: # empty = syslog
      # zabbix_agent_logfile: # empty = syslog
      zabbix_url: http://zabbixsrv.xxx:8083/
      zabbix_api_user: Admin
      zabbix_api_pass: xxx
      zabbix_api_create_hosts: zabbix_api_create_hosts_dstk
      zabbix_create_host: present
      zabbix_host_groups:
        - Linux servers
      zabbix_link_templates:
        - Template Linux Mine

Is this a bug or an error in my side?

sign_keys: add key for zabbix 3.2 on stretch

Hello

Could you add the sign_key for zabbix 3.2 on debian stretch ?

Thx

---
sign_keys:
  "34":
    stretch:
      sign_key: A14FE591
    wheezy:
      sign_key: 79EA5ED4
    jessie:
      sign_key: 79EA5ED4
    trusty:
      sign_key: 79EA5ED4
    xenial:
      sign_key: E709712C
  "32":
    stretch:
      sign_key: A14FE591
    wheezy:
      sign_key: 79EA5ED4
    jessie:
      sign_key: 79EA5ED4
    trusty:
      sign_key: 79EA5ED4
    xenial:
      sign_key: E709712C
  "30":
    wheezy:
      sign_key: 79EA5ED4
    jessie:
      sign_key: 79EA5ED4
    trusty:
      sign_key: 79EA5ED4
    xenial:
      sign_key: E709712C
  "24":
    wheezy:
      sign_key: 79EA5ED4
    jessie:
      sign_key: 79EA5ED4
    precise:
      sign_key: 79EA5ED4
    trusty:
      sign_key: 79EA5ED4
  "22":
    squeeze:
      sign_key: 79EA5ED4
    jessie:
      sign_key: 79EA5ED4
    precise:
      sign_key: 79EA5ED4
    trusty:
      sign_key: 79EA5ED4
    lucid:
      sign_key: 79EA5ED4

suse:
  "openSUSE Leap":
    "42":
      name: server:monitoring
      url: http://download.opensuse.org/repositories/server:/monitoring/openSUSE_Leap_{{ ansible_distribution_version }}/
  "openSUSE":
    "12":
      name: server_monitoring
      url: http://download.opensuse.org/repositories/server:/monitoring/openSUSE_{{ ansible_distribution_version }}
  "SLES":
    "11":
      name: server_monitoring
      url: http://download.opensuse.org/repositories/server:/monitoring/SLE_11_SP3/
...

zabbix_agent_listenip not working as expected

I tried to set zabbix_agent_listenip: 192.168.40.66 in a host_vars/omvsrv. I hoped this would set ListenIP in zabbix_agentd.conf. But this only resulted in

TASK [dj-wasabi.zabbix-agent : Fail invalid specified agent_listenip] ***********************************************************************************************************
fatal: [omvsrv]: FAILED! => {"changed": false, "failed": true, "msg": "The agent_listenip does not exist"}

The following change in /etc/ansible/roles/dj-wasabi.zabbix-agent/tasks/main.yml helped:

--- /etc/ansible/roles/dj-wasabi.zabbix-agent/tasks/main.yml.orig2      2017-09-01 06:54:56.994328475 +0200
+++ /etc/ansible/roles/dj-wasabi.zabbix-agent/tasks/main.yml    2017-09-01 06:55:26.506420556 +0200
@@ -92,6 +92,7 @@
     msg: "The agent_listenip does not exist"
   when:
     - zabbix_agent_listenip != '0.0.0.0'
+    - (zabbix_agent_listenip not in ansible_all_ipv4_addresses)
   tags:
     - zabbix-agent
     - config 

Maybe this is what you had in mind when writing this check task.

agent_ip is undefined

When one invokes playbook with

--diff --tags api

one gets:

One or more undefined variables: 'agent_ip' is undefined

zabbix_macros from defaults/main.yml

Please consider removing zabbix_macros from defaults/main.yml for by default when you create a host with zabbix web UI it defines no macros and I think there's no reason to add one.

Create hostgroups task not working as intended

The task does create host groups, but it clones the group for each host the playbook is run on.
So basically if I run it on three hosts, I end up with three identical groups (with the hosts inside all three groups).

skip zabbix_group module

Hi,

zabbix_create_hostgroup: present (Default) if you want to create hostgroups or absent if you not.
zabbix_create_host: present # or absent

zabbix_create_hostgroup param does not work as described. If I set absent it tries to delete existing hostgroup.

Our Zabbix API user has Zabbix Admin privileges and does not have perms to manage hostgroups. So we need to skip zabbix_group module. Currently we have to disable all API calls and add custom post_tasks for zabbix_host.

Thanks

create host task fails

Ansible 2.1.0.0

I've got in my var:

zabbix_link_templates:
  - "Domains Core"
  - "Generic Template"
  - "Template App Zabbix Agent"

I've got pre_task that debugs the var

TASK [Display all variables/facts known for a host] ****************************
ok: [host24-06fdmrg.linx.sbx.avp.ru] => {
    "zabbix_link_templates": [
        "Domains Core", 
        "Generic Template", 
        "Template App Zabbix Agent"
    ]
}

the main task fails with error:

FAILED! => {"changed": false, "failed": true, "msg": "Template not found: ["}

Subtle differences between SuSE and other Distributions

SuSE default installation of zabbix agent, is subtly different to other distributions:

There is a difference in the default configuration file names between (at least) SuSE and RedHat.

In CentOS/RedHat systems, the configuration file is called zabbix_agentd.conf, whereas for SuSE (11) systems, it is zabbix-agentd.conf (hyphen instead of underscore)

This means that when the service start/restart is attempted, it fails with "config not found" type error.

To get around this, I was able to make the following changes:

  1. in the vars/.yml files, add an extra parameter (zabbix_agent_conf) specifying the relevant names from above.
  2. in the tasks/main.yml file, where the template for config is set, adjust the dest to be {{zabbix_agent_conf}}

Also in the tasks/main.yml, the step "Make sure the zabbix-agent service is running" requires changing to utilise one of the already existing variables "service: name={{ zabbix_agent }}" this also reflects the differences in distributions.


Finally for consistency, in the tasks/Suse.yml file there is not a step for enabling the service, in the same way that there is for RedHat and Debian...


Regards,

Enhancing UserParameter Support

Greetings,

I've been researching the various ways that one could go about adding custom user parameters to Zabbix. Right now I have a single UserParameter that I support which lets me do iostat monitoring across my hosts. I have people scrambling to get me to support more UserParamters to monitor things like Nginx, HAProxy and Memcache (to name a few).

Unfortunately, the iostat userparamter I'm using isn't quite as simple to implement as a single iostat.conf entry to the configured 'agent_include' folder. The code I'm using (https://github.com/jizhang/zabbix-templates/tree/master/iostat) requires (in addition to the userparameter config file) a cron job to be created and run some shell scripts to run in order to compare the results of a file that is generated by the cron every minutes, and stored in the /tmp directory.

Other userparameter extensions follow the same usage scenarios:

[https://github.com/anapsix/zabbix-haproxy]

  • Executing shell scripts

[https://github.com/vicendominguez/nginx-zabbix-template]

  • Executing python scripts

[https://github.com/alfss/zabbix-redis/tree/master/redis]

  • Again calling scripts from UserParameter

I'm trying to think of some of the tasks that would need to be handled in Ansible to allow for this:

  • Create the userparameter config file for the module, obviously
  • Store any required scripts that the userparameter module uses. I would imagine that you would want to store these scripts in the Zabbix users home directory in a folder. I'm not sure were you would want to store the source of these scripts though, I would think another Git repository, but I'm not sure because I'm kind of an Ansible/Zabbix noob.
  • Create cron entires in the Zabbix user crontab that the userparameter module would require.
  • Create (touch) any tmp files that may be needed.
  • UserParameter modules can be loaded by only the hosts that need it.

Do you have any suggestions as to what might be a good path to accomplish this?

Thanks!

create host at zabbix issue

Hi,

I have problem with create host at zabbix after using useip: "{{ zabbix_useuip }}" I get info variable that is undefined The error was: [{u'ip': u'{{ agent_ip }}', u'useip': u'{{ zabbix_useuip }}', u'dns': u'{{ ansible_fqdn }}' problem exist on centos 7 and centos 6.8. Could you help me I don't know what I doing wrong?

ansible 2.2.2
my playbook looks like that

hosts: all
roles:
role: dj-wasabi.zabbix-agent
agent_server: 192.168.33.30
agent_serveractive: 192.168.33.30
zabbix_url: http://zabbix.example.com
zabbix_api_use: true # use zabbix_api_create_host and/or zabbix_api_create_hostgroup from 0.8.0
zabbix_api_user: Admin
zabbix_api_pass: zabbix
zabbix_create_host: present
zabbix_host_groups:
Linux Servers
zabbix_link_templates:
Template OS Linux
agent_interfaces:
type: 1
main: 1
useip: "{{ zabbix_useuip }}"
ip: "{{ agent_ip }}"
dns: "{{ ansible_fqdn }}"
port: "{{ agent_listenport }}"
Best
Grzegorz

zabbix apt packages are not installed due to authentication issue

When I try to install zabbix-agent or zabbix-java-gateway on Debian I get message like that

msg: '/usr/bin/apt-get -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold"   install 'zabbix-java-gateway'' failed: E: There are problems and -y was used without --force-yes

Manual apt-get update in converged host fixes the issue. I reproduce the issue in debian:8.2 docker container. But on real Debian host playbook works.

Supporting entries commented on zabbix_agentd.conf

Hello,
I think it would be useful to have some parameters config on /etc/zabbix/zabbix_agentd.d/

Maybe we can add a magic value, so:

agent_timeout: onfile 3 # create /etc/zabbix/zabbix_agentd.d/timeout.conf and comment it on zabbix_agentd.conf
agent_timeout: commented # comment Timeout directive on zabbix_agentd.conf

What do you think ?

Would you accept a patch for this ? Or you don't see it a good idea?

Thank you very much

zabbix_host_groups not working as expected

Hello.

Thank you for this ansible setup.

I have ran into an issue when for zabbix_group module:

  local_action:
    module: zabbix_group

You will notice the default one Linux servers hostgroup within Zabbix is already created as part of the zabbix server.

Now when I pass a variable for zabbix_host_groups on ansible-playbook CLI -e "zabbix_host_groups=Test Servers" so it will create the group the following happens instead:

(The reason for adding extra var at CLI, is so I can inject the zabbix group, without updating the vars file which obviously is hardcoded to a set of initial groups, were I want to do that at the CLI level when deploying the zabbix agent)

the group I called for testing is: Test Servers and what I see in Zabbix web gui, is the following groups separate instead of seeing Test Servers:
T
E
S

<127.0.0.1> login_user=api.zabbix state=present server_url=http://zabbix/zabbix/ host_groups=Test login_password=VALUE_HIDDEN
<127.0.0.1>
<127.0.0.1> login_user=api.zabbix state=present server_url=http://zabbix/zabbix/ host_groups=Test login_password=VALUE_HIDDEN
<127.0.0.1>
<127.0.0.1>
<127.0.0.1>
<127.0.0.1> 'sudo -k && sudo -H -S -p "[sudo via ansible, key=ilnwvqrkqvpmnahgmmrctijnywclyutd] password: " -u root /bin/sh -c '"'"'echo SUDO-SUCCESS-ilnwvqrkqvpmnahgmmrctijnywclyutd; LANG=C LC_CTYPE=C /usr/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1429189908.8-115910021136511/zabbix_group; rm -rf /home/ansible/.ansible/tmp/ansible-tmp-1429189908.8-115910021136511/ >/dev/null 2>&1'"'"''
<127.0.0.1> 'sudo -k && sudo -H -S -p "[sudo via ansible, key=xuqqgclkrnuiifijapuzdquiuzmduzvb] password: " -u root /bin/sh -c '"'"'echo SUDO-SUCCESS-xuqqgclkrnuiifijapuzdquiuzmduzvb; LANG=C LC_CTYPE=C /usr/bin/python /home/ansible/.ansible/tmp/ansible-tmp-1429189908.83-262271593750515/zabbix_group; rm -rf /home/ansible/.ansible/tmp/ansible-tmp-1429189908.83-262271593750515/ >/dev/null 2>&1'"'"''
changed: [192.168.1.229 -> 127.0.0.1] => {"changed": true, "result": "Successfully created host group(s): ['T', 'E', 'S', 'T']"}
changed: [192.168.1.43 -> 127.0.0.1] => {"changed": true, "result": "Successfully created host group(s): ['T', 'E']"}

Zabbix Server Can not connect the Agent

Error Info Get value from agent failed: cannot connect to xxx No route to host
Agent in OS: CentOS 6.5 and CentOS 7.x
When I stop the iptables service it works. Would you add the rules in the iptables?

creating hosts / linking templates fails

I have issue similar to this #31, but now there's no Library folder anymore.

    },
    "msg": "Hostgroup not found: Containers"
}
},
    "msg": "Template not found: Template App Zabbix Agent"
}

My config is:

  • MacOS Sierra
  • Ansible 2.2.0.0
  • installed zabbix-api via pip
  • dj-wasabi/ansible-zabbix-agent v0.9
  • Zabbix 3.2

My code:

    - role: dj-wasabi.zabbix-agent
      agent_server: "{{monitoring_server_ip}}"
      agent_serveractive: "{{monitoring_server_ip}}"
      zabbix_repo: zabbix
      zabbix_url: "{{monitoring_server_url}}"
      zabbix_api_use: true
      zabbix_api_user: "{{monitoring_api_user}}"
      zabbix_api_pass: "{{monitoring_api_password}}"
      zabbix_create_host: present
      zabbix_api_create_hosts: True
      zabbix_host_groups:
        - Containers
      zabbix_link_templates: 
        - "Template App Zabbix Agent"

Both group and template exist.

"ERROR! 'agent_ip' is undefined"

...when agent_listenip is defined (as agent_listenip: "{{ ansible_default_ipv4.address }}" )

TASK [dj-wasabi.zabbix-agent : Create a new host or update an existing host's info] ***
fatal: [xxx-hostname]: FAILED! => {"failed": true, "msg": "ERROR! 'agent_ip' is undefined"}

check if service is running

It's very strange that there's no such check in the role.
'cause you know.. It happens that someone stops zabbix for some reason and forgets about it

class ZabbixAPIExtends(ZabbixAPI): NameError: name 'ZabbixAPI' is not defined

Hi
Thank you for your beautiful zabbix agent ansible deployment code
I have this error when I try to use it

TASK [dj-wasabi.zabbix-agent : Updating host configuration with macros] ********
task path: /etc/ansible/roles/dj-wasabi.zabbix-agent/tasks/main.yml:134
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/extras/monitoring/zabbix_hostmacro.py
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: majidgolshadi
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo ~/.ansible/tmp/ansible-tmp-1485256895.75-21818523532 `" && echo ansible-tmp-1485256895.75-21818523532="` echo ~/.ansible/tmp/ansible-tmp-1485256895.75-21818523532 `" ) && sleep 0'
<localhost> PUT /tmp/tmpTr2jiO TO /home/majidgolshadi/.ansible/tmp/ansible-tmp-1485256895.75-21818523532/zabbix_hostmacro.py
<localhost> EXEC /bin/sh -c 'chmod u+x /home/majidgolshadi/.ansible/tmp/ansible-tmp-1485256895.75-21818523532/ /home/majidgolshadi/.ansible/tmp/ansible-tmp-1485256895.75-21818523532/zabbix_hostmacro.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python /home/majidgolshadi/.ansible/tmp/ansible-tmp-1485256895.75-21818523532/zabbix_hostmacro.py; rm -rf "/home/majidgolshadi/.ansible/tmp/ansible-tmp-1485256895.75-21818523532/" > /dev/null 2>&1 && sleep 0'

An exception occurred during task execution. The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible_8iV0pp/ansible_module_zabbix_hostmacro.py", line 113, in <module>
    class ZabbixAPIExtends(ZabbixAPI):
NameError: name 'ZabbixAPI' is not defined

failed: [XXX.XXX.XXX.XXX -> localhost] (item={u'macro_key': u'apache_type', u'macro_value': u'reverse_proxy'}) => {
    "failed": true, 
    "invocation": {
        "module_name": "zabbix_hostmacro"
    }, 
    "item": {
        "macro_key": "apache_type", 
        "macro_value": "reverse_proxy"
    }, 
    "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_8iV0pp/ansible_module_zabbix_hostmacro.py\", line 113, in <module>\n    class ZabbixAPIExtends(ZabbixAPI):\nNameError: name 'ZabbixAPI' is not defined\n", 
    "module_stdout": "", 
    "msg": "MODULE FAILURE"
}

Would you please help me to find out what I have to do with that?

zabbix api error

my config:

  • hosts: test
    roles:
    • role: dj-wasabi.zabbix-agent
      agent_server: xx.xx.xx.xx
      agent_serveractive: xx.xx.xx.xx
      agent_listenip: 0.0.0.0
      agent_listenport: 10050
      zabbix_version: 3.2
      zabbix_api_create_hosts: True
      zabbix_url: http://xxx.xxxx.com/zabbix
      zabbix_api_user: admin
      zabbix_api_pass: xxxxxxx
      zabbix_create_host: present
      zabbix_host_groups:
      • Linux Servers
        zabbix_link_templates:
      • Template OS Linux

and the error:
TASK [dj-wasabi.zabbix-agent : Create hostgroups] ******************************
skipping: [jiraam]

TASK [dj-wasabi.zabbix-agent : Create a new host or update an existing host's info] ***
fatal: [jiraam]: FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: [{u'ip': u'{{ agent_ip }}', u'useip': u'{{ zabbix_useuip }}', u'dns': u'{{ ansible_fqdn }}', u'main': 1, u'type': 1, u'port': u'{{ agent_listenport }}'}]: 'agent_ip' is undefined\n\nThe error appears to have been in '/etc/ansible/roles/dj-wasabi.zabbix-agent/tasks/main.yml': line 114, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: "Create a new host or update an existing host's info"\n ^ here\n"}
to retry, use: --limit @/etc/ansible/playbooks/zabbix.retry

would like for help, Thanks !

Package installation issue with Linux Mint

I'm not sure this is an issue with ansible-zabbix-agent - it seems it might actually be more into ansible but...

When applying this role to a system running the latest mint, ansible-zabbix-agent ends up using the equivalent of /etc/os-release's VERSION_CODENAME instead of UBUNTU_CODENAME when it sets up the package repository to download zabbix-agent from. On Linuxmint this are different and the ubuntu one is the appropriate one.

To reproduce: attempt to apply the role to a Linux Mint 18.2 instance.

zabbix_sender is missing

Target machine is running Ubuntu 16.04.3 LTS
Package installed is ii zabbix-agent 1:3.0.11-1+xenial amd64

zabbix_sender isn't installed. Do I need to set something to make that happen or is that a packaging problem? Note: when I attempt to execute it I get:

The program 'zabbix_sender' is currently not installed. You can install it by typing:
apt install zabbix-agent

Which "is already the newest version" when I attempt to do so. :/

'agent_interfaces' is undefined

Using 1.0.1 from ansible galaxy I get the following error:

TASK [dj-wasabi.zabbix-agent : Create a new host or update an existing host's info] *********************************************************************************************
task path: /etc/ansible/roles/dj-wasabi.zabbix-agent/tasks/main.yml:173
fatal: [docker3]: FAILED! => {
    "failed": true, 
    "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'agent_interfaces' is undefined

The error appears to have been in '/etc/ansible/roles/dj-wasabi.zabbix-agent/tasks/main.yml': line 173, column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

 
- name: \"Create a new host or update an existing host's info\" 
  ^ here
"
}

Seems a forgotten rename of agent_interfaces to zabbix_agent_interfaces and maybe others. Or could this be a problem on my side? Thank you.

PSK in variable

Hello,

There is no way to write-in PSK file content. I believe PSK file content should be writable based on variable. The variable content can be set generated eg. by lookup command.

Greetings,

SELinux Policy

I'm currently trying to test out this role against a Vagrant Box (CentOS 7.3). However, I cannot get the service to start. I believe it relates to this where they're talking about the need for a custom SELinux policy.

Has anyone else encountered this? If so, would it be possible to get this added to the role (I wouldn't mind contributing, I would just need to figure out the SELinux stuff), but I'm surprised that this hasn't been brought up or caught by anyone (or in testing).

RUNNING HANDLER [dj-wasabi.zabbix-agent : restart zabbix-agent] ********************************************************************************************
fatal: [vagrant]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to restart service zabbix-agent: Job for zabbix-agent.service failed because a configured resource limit was exceeded. See \"systemctl status zabbix-agent.service\" and \"journalctl -xe\" for details.\n"}
  5386:20170621:002521.382 using configuration file: /etc/zabbix/zabbix_agentd.conf
  5386:20170621:002521.382 cannot set resource limit: [13] Permission denied
  5386:20170621:002521.382 cannot disable core dump, exiting...
$ cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

TLS settings for host creation via API

As I am using TLS (PSK) encryption it would be great if I could pass the PSK directly to the Zabbix backend when creating a new host.

As this Role already includes the basic creation of a host in Zabbix I believe it would not be too much work to add the TLS settings. The release documentation is not yet complete but here is a comprehensive description of the required API parameters:
http://www.zabbixbook.com/2016/09/23/how-to-set-host-encryption-parameters-via-the-api/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.