GithubHelp home page GithubHelp logo

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

View Code? Open in Web Editor NEW
176.0 176.0 150.0 313 KB

Installing and maintaining zabbix-server for RedHat/Debian/Ubuntu.

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

License: MIT License

Python 100.00%

ansible-zabbix-server'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-server's People

Contributors

aminmaghsodi avatar average-joe avatar boolman avatar borener avatar clement-lefevre avatar clopnis avatar cognoscibilis avatar dj-wasabi avatar dnmvisser avatar drmikecrowe avatar envrm avatar fjcapdevila avatar fxfitz avatar grzyboll avatar kostyrev avatar kristofkeppens avatar lhoss avatar logan2211 avatar matheusrivendel avatar mescanef avatar mirmire avatar mklvr avatar mrdumpty avatar rubentsirunyan avatar santiagomr avatar srgvg avatar stephankn avatar vincepii avatar vinclame avatar wschaft 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

ansible-zabbix-server's Issues

Adding db roles which supports these 3 operating systems

You'll need to find the correct database role by yourself. I only want to use roles which supports the 3 main operating systems as well and for now I can't find one. If there is an role which supports these 3 operating systems, please let me know and I'll use it as dependency.

For postgresql:
https://galaxy.ansible.com/anxs/postgresql

Ansible role which installs and configures PostgreSQL, extensions, databases and users. Ubuntu 14.04, Ubuntu 16.04, Debian 8.x, Debian 9.x, CentOS 6.x, CentOS 7.x, Fedora latest

For mysql:
https://galaxy.ansible.com/geerlingguy/mysql

Installs and configures MySQL or MariaDB server on RHEL/CentOS or Debian/Ubuntu servers.

Upgrade from 3.4 to 4.0

Describe the bug

I'm trying to upgrade my current zabbix server from 3.4.11 to 4.0. When using this role, I notice the following task doesn't upgrade my zabbix-server-mysql package:

- name: "RedHat | Installing zabbix-server-{{ zabbix_server_database }}"
  yum:
    pkg: "{{ zabbix_server_package }}"
    state: present
  tags:
    - zabbix-server

As a result, when Zabbix tries to restart, it fails. There are unknown variables in the zabbix-server.conf preventing the service from starting.

Installation method/version

  • Github / Master

Ansible Version

  • ansible version 2.7

Targetted hosts
Concerns the following OS(es):

  • CentOS

Expected behavior

At the completion of the task, zabbix-server service should successfully restart.

Additional context

To validate, after manually installing the latest zabbix-server-mysql package, zabbix-server service does successfully restart.

unable to install older releases of zabbix-server

Describe the bug

Hey @dj-wasabi. I am trying to install all supported LTS releases of zabbix-server, but failing to do so with 2.2 and 3.0 LTS (sorry for merging these issues, if you prefer them separated just let me know).

  • zbx server 2.2 on ubuntu 14.04 (seems those files are in /usr/share/zabbix-server-mysql/):
TASK [dj-wasabi.zabbix-server : Get the correct path for the SQL files < 3.0] *************************************************************************************************************************************************************************************************
failed: [zbx-dev-node001] (item=schema) => {"changed": false, "cmd": "ls -1 /usr/share/zabbix-server-mysql/create/schema.sql*", "delta": "0:00:00.002818", "end": "2018-11-12 14:18:49.521563", "item": "schema", "msg": "non-zero return code", "rc": 2, "start": "2018-11-12
14:18:49.518745", "stderr": "ls: cannot access /usr/share/zabbix-server-mysql/create/schema.sql*: No such file or directory", "stderr_lines": ["ls: cannot access /usr/share/zabbix-server-mysql/create/schema.sql*: No such file or directory"], "stdout": "", "stdout_lines":
 []}
failed: [zbx-dev-node001] (item=images) => {"changed": false, "cmd": "ls -1 /usr/share/zabbix-server-mysql/create/images.sql*", "delta": "0:00:00.003094", "end": "2018-11-12 14:18:50.452417", "item": "images", "msg": "non-zero return code", "rc": 2, "start": "2018-11-12
14:18:50.449323", "stderr": "ls: cannot access /usr/share/zabbix-server-mysql/create/images.sql*: No such file or directory", "stderr_lines": ["ls: cannot access /usr/share/zabbix-server-mysql/create/images.sql*: No such file or directory"], "stdout": "", "stdout_lines":
 []}
failed: [zbx-dev-node001] (item=data) => {"changed": false, "cmd": "ls -1 /usr/share/zabbix-server-mysql/create/data.sql*", "delta": "0:00:00.003127", "end": "2018-11-12 14:18:51.388705", "item": "data", "msg": "non-zero return code", "rc": 2, "start": "2018-11-12 14:18:
51.385578", "stderr": "ls: cannot access /usr/share/zabbix-server-mysql/create/data.sql*: No such file or directory", "stderr_lines": ["ls: cannot access /usr/share/zabbix-server-mysql/create/data.sql*: No such file or directory"], "stdout": "", "stdout_lines": []}
  • zbx server 3.0 on ubuntu 16.04
TASK [dj-wasabi.zabbix-server : Zabbix-server started] ************************************************************************************************************************************************************************************************************************
fatal: [zbx-dev-node002]: FAILED! => {"changed": false, "msg": "Unable to start service zabbix-server: Job for zabbix-server.service failed because the control process exited with error code. See \"systemctl status zabbix-server.service\" and \"journalctl -xe\" for detai
ls.\n"}

Info from journalctl -u zabbix-server

Nov 12 14:19:22 zbx-dev-node002 systemd[1]: Starting Zabbix Server...
Nov 12 14:19:22 zbx-dev-node002 zabbix_server[9433]: zabbix_server [9433]: unknown parameter "SocketDir" in config file "/etc/zabbix/zabbix_server.conf", line 54
Nov 12 14:19:22 zbx-dev-node002 systemd[1]: zabbix-server.service: Control process exited, code=exited status=1
Nov 12 14:19:22 zbx-dev-node002 systemd[1]: Failed to start Zabbix Server.

Installation method/version

  • Ansible Galaxy / 1.3.0

Ansible Version

ansible 2.7.0

Targetted hosts
Concerns the following OS(es):

  • Ubuntu

Expected behavior

No errors with those tasks :)

Additional context

Playbook + inventory if it helps you to better understand my dev env:

- hosts: zbx-dev-nodes
  name: Configures hosts to run standalone zabbix-server installations with specified versions
  vars:
    mysql_bind_address: '127.0.0.1'
    zabbix_version: '{{ zbx_version }}'
    zabbix_url: '{{ ansible_host }}'
    zabbix_server_database: mysql
    zabbix_server_database_long: mysql

  roles:
    - geerlingguy.mysql
    - geerlingguy.apache
    - dj-wasabi.zabbix-server
    - dj-wasabi.zabbix-web
[zbx-dev-nodes]
# Testing servers will run LTS releases of Zabbix server
# terraform creates host_vars/ files for these hosts with ansible_host directive
zbx-dev-node001 zbx_version=2.2
zbx-dev-node002 zbx_version=3.0
zbx-dev-node003 zbx_version=4.0

zabbix_repo - inconsistent use between server and agent roles.

In ansible-zabbix-server, zabbix_repo is a boolean, whereas (following some adjustments for epel handling) zabbix_repo is a string.

When hooking both roles into a playbook, ansible-playbook barfs:

TASK: [dj-wasabi.zabbix-server | RedHat | Install basic repo file] ************
fatal: [xxx.xxx.xxx.xxx] => error while evaluating conditional: zabbix

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************

to retry, use: --limit @/root/install-zabbix-server.retry

I have tweaked my local installation, to get around this issue (but only for my exact use case - installing zabbix server + agent on CentOS 7)

Is there any merit in adjusting the zabbix_repo in ansible-zabbix-server to match the agent role, or is it bad practice to try and wrap both of these roles into one playbook anyway ?!!

ansible-zabbix-server/tasks/postgresql.yml does not allow connection to the database without ssh

Describe the bug
ansible-zabbix-server/tasks/postgresql.yml does not allow connection to the database without ssh, ssh shouldn't be a requirement as login_host, login_password, login_user can provide the access needed to connect to an existing postgredb

Installation method/version

  • Github / latest

Ansible Version

<!--- Paste output from "ansible --version" -->

Targetted hosts
Concerns the following OS(es):

  • Ubuntu
  • Debian
  • CentOS
  • Mint

Expected behavior
Should connect to a Postgre db and create the db and user as requested

"always" tag in role hinders it usage with ansible-playbook -t

subj
without 'always'

>ansible-playbook -i production zabbix.yml -t zabbix_backup_cron --list-tasks

playbook: zabbix.yml

  play #1 (monitoring-server): monitoring-server        TAGS: []
    tasks:
      include   TAGS: [mysql]
      include   TAGS: [mysql]
      include   TAGS: [apache]
      include   TAGS: [apache]
      include   TAGS: [zabbix-server]
      include   TAGS: [zabbix-server]
      add backup task for zabbix db     TAGS: [zabbix_backup_cron]

and with 'always'

>ansible-playbook -i production zabbix.yml -t zabbix_backup_cron --list-tasks

playbook: zabbix.yml

  play #1 (monitoring-server): monitoring-server        TAGS: []
    tasks:
      include   TAGS: [mysql]
      include   TAGS: [mysql]
      include   TAGS: [apache]
      include   TAGS: [apache]
      include   TAGS: [zabbix-server]
      include   TAGS: [zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Set short version name TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Use Zabbix package name        TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Use EPEL package name  TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Set some facts EPEL    TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Set some facts Zabbix  TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Set facts for Zabbix 3.0       TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Install basic repo file        TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Installing zabbix-server-{{ database_type }}   TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Install zabbix-web-{{ database_type }} TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Install apache vhost   TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Install Ansible module dependencies    TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Install Mysql Client package RHEL7     TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Install Mysql Client package RHEL5 - 6 TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Install PostgreSQL client package      TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Install related SELinux package        TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Enable httpd_can_connect_zabbix SELinux boolean        TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : RedHat | Enable zabbix_can_network SELinux boolean      TAGS: [always, zabbix-server]
      dj-wasabi.zabbix-server : Debian | Set some facts TAGS: [always, config, init, zabbix-server]
      dj-wasabi.zabbix-server : Debian | Set some facts for Zabbix 3+   TAGS: [always, config, init, zabbix-server]
...

moreover, with always tag play fail with error

>ansible-playbook -i production zabbix.yml -t zabbix_backup_cron
....
TASK [dj-wasabi.zabbix-server : Debian | install apache vhost] *********************************************************************************************************************************************
fatal: [myserver.msk.termika.ru]: FAILED! => {"changed": false, "failed": true, "msg": "AnsibleUndefinedVariable: 'apachectl_version' is undefined"}

because

- name: "Get Apache version"
- name: "Set correct apache_version"

not running

Wrong datafiles_path for RedHat Zabbix version < 3.0

Issue is related to the defined path which is used in the following task

TASK [dj-wasabi.zabbix-server : Get the correct path for the SQL files < 3.0]
***********************************
failed: [hostname] (item=schema) => {"changed": false, "cmd": "ls -1 /usr/share/doc/zabbix-server-mysql-2.4*/create/create/schema.sql*", "delta": "0:00:00.004374", "end": "2018-09-04 14:48:08.492045", "item": "schema", "msg": "non-zero return code", "rc": 2, "start": "2018-09-04 14:48:08.487671", "stderr": "ls: cannot access /usr/share/doc/zabbix-server-mysql-2.4*/create/create/schema.sql*: No such file or directory", "stderr_lines": ["ls: cannot access /usr/share/doc/zabbix-server-mysql-2.4*/create/create/schema.sql*: No such file or directory"], "stdout": "", "stdout_lines": []}
failed: [hostname] (item=images) => {"changed": false, "cmd": "ls -1 /usr/share/doc/zabbix-server-mysql-2.4*/create/create/images.sql*", "delta": "0:00:00.004859", "end": "2018-09-04 14:48:09.330436", "item": "images", "msg": "non-zero return code", "rc": 2, "start": "2018-09-04 14:48:09.325577", "stderr": "ls: cannot access /usr/share/doc/zabbix-server-mysql-2.4*/create/create/images.sql*: No such file or directory", "stderr_lines": ["ls: cannot access /usr/share/doc/zabbix-server-mysql-2.4*/create/create/images.sql*: No such file or directory"], "stdout": "", "stdout_lines": []}
failed: [hostname] (item=data) => {"changed": false, "cmd": "ls -1 /usr/share/doc/zabbix-server-mysql-2.4*/create/create/data.sql*", "delta": "0:00:00.004480", "end": "2018-09-04 14:48:10.170804", "item": "data", "msg": "non-zero return code", "rc": 2, "start": "2018-09-04 14:48:10.166324", "stderr": "ls: cannot access /usr/share/doc/zabbix-server-mysql-2.4*/create/create/data.sql*: No such file or directory", "stderr_lines": ["ls: cannot access /usr/share/doc/zabbix-server-mysql-2.4*/create/create/data.sql*: No such file or directory"], "stdout": "", "stdout_lines": []}

This issue is due to the set_fact task in the RedHat.yml file:

- name: "RedHat | Set some facts Zabbix < 3.0"
  set_fact:
    datafiles_path: "/usr/share/doc/zabbix-server-{{ zabbix_server_database }}-{{ zabbix_version }}*/create"
  when:
    - zabbix_version is version_compare('3.0', '<')
  tags:
    - zabbix-server

By removing the /create at the end of the path definition it is working as expected.

Installation method/version

  • Github / latest
  • Ansible Galaxy / 1.1.0

Ansible Version
2.6.1

Targetted hosts
Concerns the following OS(es):

  • CentOS

Expected behavior
Successful execution of the whole role by using the correct paths.

Additional context

sign_keys not found

Hi,

I'm running the latest Ubuntu 18.04 and ansible 2.6.5
I've installed this role via ansible-galaxy and have the following playbook:

ansible-galaxy install dj-wasabi.zabbix-server

- name: Install Zabbix Server
  become: yes
  tags:
    - zabbix_server
  hosts: monitoring_elk
  roles:
    - role: dj-wasabi.zabbix-server
      database_type: "{{ zabbix_server_database }}"
      database_type_long: "{{ zabbix_server_database_long }}"
  vars:
    zabbix_server_name: "iws-monitoring"
    zabbix_server_database: "pgsql"
    zabbix_server_database_long: "postgresql"
    zabbix_server_dbhost: "{{ hostvars[groups.monitoring_elk[0]].ansible_default_ipv4['address'] }}"
    zabbix_server_dbname: "iws_monitoring"
    zabbix_server_dbuser: "iws01"
    zabbix_server_dbpassword: "f2l9fdhj8fFHI$=ยงw0fy0Zne"
    zabbix_server_dbport: "5432"
    zabbix_server_database_creation: true
    zabbix_version: 4.0

When I'm exectuing this, it ends up with the following message:
FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'sign_keys' is undefined\n\nThe error appears e/roles/dj-wasabi.zabbix-server/tasks/Debian.yml'

Apache vhost config installed to wrong directory in Debian

In Debian/Ubuntu websites are installed to /etc/apache2/sites-available and only symlinked to /etc/apache2/sites-enabled.
This role ignores this convention and directly creates the config from the template in the sites-enabled directory.

consider releasing a new version as 0.7 is quite old

Would be great to see a newer version than 0.7 tagged, maybe even as release.

There had been quite a few fixes since last December. How about making them officially available?

At least I feel better syncing to a more officially approved release than just to a commit hash.

"Failed to connect to bus: No such file or directory" on Ubuntu CI

Issue when Ubuntu is used during CI build:

    TASK [ansible-zabbix-server : Zabbix-server started] ***************************
    fatal: [zabbix-server-mysql-ubuntu]: FAILED! => {"changed": false, "cmd": "/bin/systemctl", "failed": true, "msg": "Failed to connect to bus: No such file or directory", "rc": 1, "stderr": "Failed to connect to bus: No such file or directory\n", "stderr_lines": ["Failed to connect to bus: No such file or directory"], "stdout": "", "stdout_lines": []}
    fatal: [zabbix-server-pgsql-ubuntu]: FAILED! => {"changed": false, "cmd": "/bin/systemctl", "failed": true, "msg": "Failed to connect to bus: No such file or directory", "rc": 1, "stderr": "Failed to connect to bus: No such file or directory\n", "stderr_lines": ["Failed to connect to bus: No such file or directory"], "stdout": "", "stdout_lines": []}

systemd service zabbix-server not enabled on Ubuntu 16.04

I did a clean install on a 16.04.2 LTS (Xenial Xerus) test machine.
after installation the Zabbix server is running (confirmed by systemctl and web interface).

$ sudo systemctl status zabbix-server
โ— zabbix-server.service - Zabbix Server
   Loaded: loaded (/lib/systemd/system/zabbix-server.service; disabled; vendor preset: enabled)
   Active: active (running) since Fri 2017-06-16 19:43:47 UTC; 28s ago
  Process: 9507 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)

Unfortunately this already shows that the service is started, but not enabled. So after the next reboot it will not run.

My ansible install is on latest. I saw some reports about conflicts between systemd and sysV init scripts confusing ansible, but thought these are fixed in ansible/ansible-modules-core#3764

 $ ansible --version
ansible 2.4.0 (devel 5f23aa69c6) last updated 2017/06/16 19:27:24 (GMT +000)
  config file = /home/vagrant/playbook/ansible.cfg
  configured module search path = [u'/home/vagrant/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/vagrant/ansible/lib/ansible
  executable location = /home/vagrant/ansible/bin/ansible
  python version = 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2]

This seems to be an ansible issue but due to this issue it won't properly bring up a new installation.
I have commented about this on ansible/ansible#22303

It can be fixed by manually enabling the service, but this defeats a bit the purpose auf automation by ansible.
systemctl enable zabbix-server.service

Even in case ansible gets fixed eventually in the future, this does not help for existing installs. How about adding a workaround to the handler as suggested in the ansible bugtracker?

service: name=zabbix-server state=restarted enabled=yes use=service

As the handler is not triggered without a change, it will not repair existing setups by running the playbook again.

Having another task (not a handler) requesting the service being started at the end might solve this.
service: name=zabbix-server state=started enabled=yes use=service

Database creation using create.sql.gz

Describe the bug

While trying to install a fresh Zabbix server instance on a CentOS instance, the playbook will fail during the database creation.

Specifically, failing on this task:

- name: "MySQL | Create database and import file >= 3.0"
  mysql_db:
    login_host: "{{ zabbix_server_mysql_login_host | default(omit) }}"
    login_user: "{{ zabbix_server_mysql_login_user | default(omit) }}"
    login_password: "{{ zabbix_server_mysql_login_password | default(omit) }}"
    login_port: "{{ zabbix_server_mysql_login_port | default(omit) }}"
    login_unix_socket: "{{ zabbix_server_mysql_login_unix_socket | default(omit) }}"
    name: "{{ zabbix_server_dbname }}"
    encoding: "{{ zabbix_server_dbencoding }}"
    collation: "{{ zabbix_server_dbcollation }}"
    state: import
    target: "{{ ls_output_create.stdout }}"
  when:
    - zabbix_version is version_compare('3.0', '>=')
    - zabbix_database_sqlload
    - not done_file.stat.exists
  delegate_to: "{{ delegated_dbhost }}"
  tags:
    - zabbix-server
    - database

It appears the mysql_db ansible module is unable to unzip the .gz file prior to use. After manually unzipping the create.sql.gz file and then running the playbook again, it will succeed.

Installation method/version

  • Github / latest

Ansible Version
Recently upgraded to Ansible 2.7.

<!--- Paste output from "ansible --version" -->
TASK [dj-wasabi.zabbix-server : MySQL | Create database and import file >= 3.0] **************************************************

<192.168.XX.24> (1, '\r\n\r\n{"msg": "\\ngzip: stdout: Broken pipe\\n", "failed": true, "invocation": {"module_args": {"ssl_key": null, "login_port": 3306, "config_file": "/root/.my.cnf", "target": "/usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz", "encoding": "utf8", "login_user": "root", "login_host": "localhost", "ignore_tables": [], "ssl_ca": null, "login_unix_socket": null, "state": "import", "ssl_cert": null, "login_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "collation": "utf8_bin", "quick": true, "single_transaction": false, "connect_timeout": 30, "name": "zabbixdb"}}}\r\n', 'Shared connection to 192.168.XX.24 closed.\r\n')
<192.168.XX.24> ESTABLISH SSH CONNECTION FOR USER: ansible
<192.168.XX.24> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ansible -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/89a7234a26 192.168.XX.24 '/bin/sh -c '"'"'rm -f -r /home/ansible/.ansible/tmp/ansible-tmp-1539869748.41-273338602067385/ > /dev/null 2>&1 && sleep 0'"'"''
<192.168.XX.24> (0, '', '')
fatal: [lab-cms-zabbix.temp -> 192.168.XX.24]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "collation": "utf8_bin",
            "config_file": "/root/.my.cnf",
            "connect_timeout": 30,
            "encoding": "utf8",
            "ignore_tables": [],
            "login_host": "localhost",
            "login_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "login_port": 3306,
            "login_unix_socket": null,
            "login_user": "root",
            "name": "zabbixdb",
            "quick": true,
            "single_transaction": false,
            "ssl_ca": null,
            "ssl_cert": null,
            "ssl_key": null,
            "state": "import",
            "target": "/usr/share/doc/zabbix-server-mysql-4.0.0/create.sql.gz"
        }
    },
    "msg": "\ngzip: stdout: Broken pipe\n"

Targetted hosts
Concerns the following OS(es):

  • CentOS

Expected behavior

The task should succeed and correctly build the zabbix database.

Additional context

I don't recall running into this problem when using Ansible v2.5. Is anyone able to replicate this problem with v2.7?

Fails on "Configure zabbix-web" step

TASK [dj-wasabi.zabbix-server : Configure zabbix-web] **************************
fatal: [cluster]: FAILED! => {"changed": true, "failed": true, "msg": "Destination directory /etc/zabbix/web does not exist"}

My custom config (all other things are default):
cluster zabbix_url=cluster zabbix_timezone=UTC database_type=pgsql database_type_long=postgresql server_dbname=zabbix server_dbuser=zabbix

Zabbix Server Install -- Fails with MySQL

I'm trying to use this role to setup and configure a Zabbix Server on CentOS 7, however I can't get it to pass the MySQL part. Am I doing something wrong?

TASK [dj-wasabi.zabbix-server : MySQL | Create database] *******************************
fatal: [vagrant-cms-zabbix.cyclops -> 192.168.200.11]: FAILED! => {"changed": false, "failed": true, "msg": "unable to find /root/.my.cnf. Exception message: (2002, \"Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)\")"}

Relevant configuration:

zabbix_version: 3.2
zabbix_repo: zabbix
zabbix_agent_package_state: latest
zabbix_selinux: true
zabbix_timezone: UTC
zabbix_web: true
zabbix_database_creation: true
zabbix_database_sqlload: true
database_type: mysql
database_type_long: mysql
server_dbport: 3306

datafiles_path for Zabbix 3.2.1 wrong on RedHat

The logic in tasks/RedHat.yml sets the datafiles_path wrongly to /usr/share/doc/zabbix-server-{{ database_type }}-{{ zabbix_version }}*/create for Zabbix 3.2.1 (3.2.* ?).

The correct path should be"/usr/share/doc/zabbix-server-{{ database_type }}-{{ zabbix_version }}* as for Zabbix 3.0.

Installation fails on Debian with sysvinit

Describe the bug

Installation of Zabbix fails on Debian systems which don't have systemd:

fatal: [zabbix]: FAILED! => {"changed": false, "msg": "Failed to find required executable systemctl in paths: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}

Installation method/version

  • Ansible Galaxy / 1.2.0

Ansible Version

ansible 2.7.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516]

Targetted hosts

Concerns the following OS(es):

  • Debian stretch

Expected behavior

The module should detect that systemd is not available and fall back to using sysvinit instead.

Zabbix 4

All's the title, I see this is good to go up to Zabbix 3.4. Can you add version 4 ?

alertscripts path is incorrect

Describe the bug
zabbix_server_alertscriptspath: ${datadir}/zabbix/alertscripts is incorrect (defaults/main.yml) - alertscripts are located in /usr/lib/zabbix/alertscripts, a directory which exists. There's nothing to create this directory, and in fact, since it uses ${datadir}, it isn't even possible to have ansible do anything with it. It can't create it or install scripts into it.

I propose setting it to /usr/lib/zabbix/alertscripts explicitly.

seperation between mysql and postgress

Hello
even when we create a mysql database both PostgreSQL and MySQL dependencies are require
name: "RedHat | Install Ansible module dependencies" yum: name=python-psycopg2 state=present when: zabbix_database_creation tags: zabbix-server

need to be separated mysql/postgress

Seboolean Error

Describe the bug
When running the latest update, the playbook is failing on this task:

- name: "RedHat | Enable httpd_can_connect_zabbix SELinux boolean"
  seboolean:
    name:
      - httpd_can_connect_zabbix
    state: yes
    persistent: yes
  when:
    - selinux_allow_zabbix_can_http
  tags:
    - zabbix-server

The resulting error is:

FAILED! => {"changed": false, "msg": "SELinux boolean ['httpd_can_connect_zabbix'] does not exist."}

Has anyone seen this error before? Any ideas for resolution?

Installation method/version

  • Github / latest (Master - 41ecd78)

Ansible Version

  • 2.7.0

Targetted hosts
Concerns the following OS(es):

  • CentOS 7

Expected behavior
For the task to be completed successfully.

Additional context
When attempting to run this manually on the host I do not get an error:
setsebool -P httpd_can_connect_zabbix 1

Release 1.0.0 - Issue/Task List

@dj-wasabi: I'd like to help as much as I can speed along the release of 1.0.0 for all of your Zabbix roles (we're using them extensively at this point).

What would you think about defining some issues/tasks that you'd like to see done in order to get 1.0.0 out the door so I can start contributing?

Thanks!

zabbix_server_database variable not used

variables
zabbix_server_database: The type of database used. Can be: mysql or pgsql
zabbix_server_database_long: The type of database used, but long name. Can be: mysql or postgresql

mentioned only in readme.md
role itself still using database_type, database_type_long

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)\")"

When i tried to install zabbix server 3.2 in centos7.3 ,the mysql database cannot be created.

The error message is:

TASK [dj-wasabi.zabbix-server : MySQL | Create database] ***********************
fatal: [zabbix.paastest.cn -> zabbix.paastest.cn]: FAILED! => {"changed": false, "failed": true, "msg": "unable to find /root/.my.cnf. Exception message: (2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)")"}
to retry, use: --limit @/etc/ansible/roles/main.retry

The DB has been installed in the host:
Package 1:mariadb-5.5.52-1.el7.x86_64 already installed and latest version

Ubuntu 16.04 - unable to install - wrong PHP dependency

TASK [dj-wasabi.zabbix-server : Debian | Install php5-mysql] *******************
fatal: [192.168.0.171]: FAILED! => {"changed": false, "failed": true, "msg": "No package matching 'php5-mysql' is available"}

On Ubuntu 16.04 there is only php7.0-mysql package, you should probably depend on php-mysql virtual package

Security problem config file

Hello!

- name: "Configure zabbix-server"                                                                                                                                                                           
  template:                                                                                                                                                                                                 
    src: zabbix_server.conf.j2                                                                                                                                                                              
    dest: /etc/zabbix/zabbix_server.conf                                                                                                                                                                    
    owner: zabbix                                                                                                                                                                                           
    group: zabbix                                                                                                                                                                                           
    mode: 0644                                                                                                                                                                                              
  notify:                                                                                                                                                                                                   
    - zabbix-server restarted                                                                                                                                                                               
  tags:                                                                                                                                                                                                     
    - zabbix-server                                                                                                                                                                                         
    - init                                                                                                                                                                                                  
    - config     

Mode file 0644 not good, may be 0640 .
Same thing in zabbix-web role.

Creating MySQL database fails with "the python mysqldb module is required"

TASK: [dj-wasabi.zabbix-server | MySQL | Create database] *********************
failed: [10.133.77.213] => {"failed": true}
msg: the python mysqldb module is required

FATAL: all hosts have already failed -- aborting

Here's my playbook:

- name: Setting up staging server
  hosts: zabbix.example.com
  roles:
    # ansible-galaxy install dj-wasabi.zabbix-server
    - role: dj-wasabi.zabbix-server
      zabbix_version: 2.4
      zabbix_url: zabbix.example.com
      database_type: mysql
      database_type_long: mysql

PostgreSQL questions

Does this role assume that Postgresql user and group are created before hand or it assumes that postgresql installation creates them? Because on Centos 7 it seems that postgresql does not do these things.

Also it seems that PostgreSQL will not even come up with this role. Postgresql-server and postgresql-contrib are not installed so the service is not even existing. Does the role assume that the server is also pre installed already?

Wrong directory api instead of app in apache_vhost.conf.j2

Hello, I found little typo in template apache_vhost.conf.j2 on line 10:

{% set directory_paths = ['/usr/share/zabbix/conf', '/usr/share/zabbix/api', '/usr/share/zabbix/include', '/usr/share/zabbix/include/classes'] %}

Instead of '/usr/share/zabbix/api' there should be correct path '/usr/share/zabbix/app'

Thanks for great playbook

Failed to set permissions on the temporary files

Describe the bug

This has been reported on #29 but it's happening everytime with me.

The following message is thrown when running the Create Database task:

TASK [dj-wasabi.zabbix-server : PostgreSQL | Delegated | Create database] ********************************************************************************

fatal: [192.168.170.134]: FAILED! => {"msg": "Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user (rc: 1, err: chown: changing ownership of '/var/tmp/ansible-tmp-1549076605.5-17742358543893/': Operation not permitted\nchown: changing ownership of '/var/tmp/ansible-tmp-1549076605.5-17742358543893/AnsiballZ_postgresql_db.py': Operation not permitted\n}). For information on working around this, see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user"}

Installation method/version

  • Ansible Galaxy / 1.3

Ansible Version

2.7.6

Targetted hosts
Concerns the following OS(es):

  • Ubuntu 18.04
  • Debian 9.5

Expected behavior

Additional context

Support for v3+ Server Configuration

(bug: v2 only, must be v2+v3)
StartTimers={{ server_starttimers }}
StartVMwareCollectors={{ server_startvmwarecollectors }}
ValueCacheSize={{ server_valuecachesize }}
AllowRoot={{ server_allowroot }}
LoadModulePath={{ server_loadmodulepath }}

v3+ (or may be earlier, but not supported now)
StartEscalators={{ server_startescalators }}
VMwarePerfFrequency={{ server_vmwareperffrequency }}
VMwareTimeout={{ server_vmwaretimeout }}
HistoryIndexCacheSize={{ server_historyindexcachesize }}
User={{ server_user }}

ssl:
SSLCertLocation=${datadir}/zabbix/ssl/certs
SSLKeyLocation=${datadir}/zabbix/ssl/keys
SSLCALocation=

btw, mysql_db module support import from sql.gz - unpacking not needed
I solve it this way:

  • name: "MySQL | Create database"
    mysql_db: name={{ server_dbname }}
    state=present
    when: zabbix_database_creation
    tags:
    • zabbix-server
    • database
      register: zabbix_database_created
  • name: "MySQL | Importing data file v3+"
    mysql_db:
    state: import
    name: "{{ server_dbname }}"
    target: "{{ datafiles_path }}/create.sql.gz"
    login_host: "{{ server_dbhost }}"
    login_user: "{{ server_dbuser }}"
    login_password: "{{ server_dbpassword }}"
    when: zabbix_database_sqlload and zabbix_version >= 3 and zabbix_database_created.changed == true
    tags:
    • zabbix-server
    • database

Is installation over Tunnel-SSH possible?

Hello,

we have to much Firewall-Rules and its not possible to open any ports to any zabbix-Server/Proxy/Agent. It is possible to tunnel youre playbook over SSH Tunnel automaticaly?

dj-wasabi.zabbix-server : PostgreSQL | Create database permissions error

I am receiving the following error when trying to install 3.2 on RHEL 7.2 with PostgreSQL at TASK [dj-wasabi.zabbix-server : PostgreSQL | Create database]:

fatal: [usor7dzabx01]: FAILED! => {"failed": true, "msg": "Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user. For information on working around this, see https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user"}.

I've tried modifying the task in the playbook to resolve with no luck. Running as a sudoer.

dj-wasabi.zabbix-server : MySQL | Create database exception: cannot connect

Receiving the following error when trying to install 3.2 on RHEL 7.2 with MySQL at TASK [dj-wasabi.zabbix-server : MySQL | Create database]:

fatal: [usor7dzabx01 -> usor7dzabx01]: FAILED! => {"changed": false, "failed": true, "msg": "unable to find /root/.my.cnf. Exception message: (2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)")"}

Random other issues with configuration on RHEL 7.2

After completing the playbook run successfully I had to resolve several other issues with the Zabbix 3.2.1 install using PostgreSQL on RHEL 7.2:

  • I had to drop the database and recreate it as zabbix, then change the ownership to zabbix-server in PostgreSQL. Zabbix-server was throwing an error that it was not a Zabbix database otherwise. Had to blank DBHost in zabbix.conf and change DBName. Required reboot for all changes to be noticed.

  • Had to install zabbix-java-gateway to make web interface work and updated httpd configs to look for zabbix on port 8080 as there are pre-configured vhosts using port 80 with the dependent apache playbook.

  • SELINUX is a problem as usual, either disable it or add a policy for zabbix using "setsebool -P zabbix_can_network 1".

Hope this info is helpful in your updates.

installation does not create database on remote host

Describe the bug

If using a remote db host, the role sets delegated_db_host and uses this later to install create.sql.gz. The problem is that create.sql.gz exists on the Zabbix host, not on the remote db host.

TASK [zabbix-server : MySQL | Create database and import file >= 3.0] ***********************************************************************
fatal: [zabbix -> support.scl01.filon.tech]: FAILED! => {"changed": false, "msg": "target /usr/share/doc/zabbix-server-mysql/create.sql.gz does not exist on the host"}

Installation method/version

  • Github / latest

Ansible Version

ansible 2.5.2
  config file = /home/ubuntu/ansible/ansible.cfg
  configured module search path = [u'/home/ubuntu/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ubuntu/ansible/venv/local/lib/python2.7/site-packages/ansible
  executable location = /home/ubuntu/ansible/venv/bin/ansible
  python version = 2.7.12 (default, Dec  4 2017, 14:50:18) [GCC 5.4.0 20160609]

Targetted hosts
Concerns the following OS(es):

  • Ubuntu

Expected behavior

The database should have been installed.

Additional context

I'm working on a resolution and will submit a PR if it works.

zabbix_short_version tests are sometimes testing integer, sometimes testing strings

There are several parts in the repository, especially in templates/zabbix_server.conf.j2 with mixed tests, testing both string and integer along the file.

In YAML files, tests are stating zabbix_short_version is an integer while it is a string by construction:
zabbix_short_version: "{{ zabbix_version | regex_replace('\\.', '') }}"

This leads to this kind of fail:

fatal:foobar: FAILED! => {"failed": true, "msg": "The conditional check 'zabbix_short_version < 30' failed. The error was: Unexpected templating type error occurred on ({% if zabbix_s
hort_version < 30 %} True {% else %} False {% endif %}): '<' not supported between instances of 'str' and 'int'\n\nThe error appears to have been in '/foo/bar/ansible/roles/zabbix-serv
er/tasks/Debian.yml': line 2, 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: \"Debian | Set some facts\"\n  ^ here\n"} 

About this issue, and compared to other versions, what was the need to create this zabbix_short_version (why short by the way?) cutting out the dot in the version? Or setting this directly if this is really needed, as it looks like zabbix_version is only used to create zabbix_short_version?

EDIT: It looks like Zabbix 3.4 is now out. Repository might need an update to add support for it in the same time on some of those tests. But this might need another issue/PR.

No dependencies listed in meta file.

Is there a reason you are not listing the following roles as dependencies in your ansible-galaxy meta file?

  • geerlingguy.apache
  • geerlingguy.mysql
  • geerlingguy.postgresql

Ansible Galaxy Dependencies

Roles can also be dependent on other roles, and when you install a role that has dependencies, those dependencies will automatically be installed.

unable to connect to database

Hello

I got below err

fatal: [xx -> xxx]: FAILED! => {"changed": false, "msg": "unable to connect to database, check login_user and login_password are correct or /root/.my.cnf has the credentials. Exception message: (2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)")"}

i am using
ansible 2.4.2.0

Destination host is RHEL 7

pls suggest thx

Extract zabbix-web component from role ?

At the moment it's possible to skip installation of the zabbix-web component, but there are other steps in the tasks that perform tasks related to zabbix-web regardless of it's installation ( such as installing php packages etc. ).

Since all other zabbix components are extracted to their separate role ( proxy, javagateway, agent ) wouldn't it make sense to move all zabbix-web related steps to its own ansible role? I would be happy to help with this effort.

As an alternative, would you welcome a pull request that disables all zabbix-web related steps based on the variable to select zabbix-web installation?

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.