ansible zabbix

[root@localhost ~]# cat snap.yml
---

- name: Install zabbix
  hosts: localhost
  connection: local
  gather_facts: no
  tasks:
    - name: Install zabbix repo
      yum:
       name: http://repo.zabbix.com/zabbix/4.3/rhel/7/x86_64/zabbix-release-4.3-3.el7.noarch.rpm
       state: present
    - name: Install zabbix40
      yum:
       name: zabbix40
       state: absent
    - name: Install zabbix agent
      yum:
       name: zabbix-agent
       state: present
    - name: Install zabbix server
      yum:
       name: zabbix-server
       state: present
    - name: Install zabbix server mysql
      yum:
       name: zabbix-server-mysql
       state: present
    - name: Install zabbix web mysql
      yum:
       name: zabbix-web-mysql
       state: present

[root@localhost ~]#


[root@localhost ~]# ansible-playbook zabbix.yml

PLAY [Create a VM] ********************************************************************

TASK [Install zabbix repo] ************************************************************
ok: [localhost]

TASK [Install zabbix40] ***************************************************************
changed: [localhost]

TASK [Install zabbix agent] ***********************************************************
changed: [localhost]

TASK [Install zabbix server] **********************************************************
changed: [localhost]

TASK [Install zabbix server mysql] ****************************************************
changed: [localhost]

TASK [Install zabbix web mysql] *******************************************************
changed: [localhost]

PLAY RECAP ****************************************************************************
localhost                  : ok=6    changed=5    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0 

[root@localhost ~]# rpm -qa | grep zabbix
zabbix-server-mysql-4.4.0-0.3alpha3.el7.x86_64
zabbix-agent-4.4.0-0.3alpha3.el7.x86_64
zabbix-web-4.4.0-0.3alpha3.el7.noarch
zabbix-web-mysql-4.4.0-0.3alpha3.el7.noarch
zabbix-server-pgsql-4.4.0-0.3alpha3.el7.x86_64
zabbix-release-4.3-3.el7.noarch
[root@localhost ~]#
[root@localhost ~]# mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@localhost ~]# service mysql start
Redirecting to /bin/systemctl start mysql.service
Failed to start mysql.service: Unit not found.
[root@localhost ~]# service mariadb start
Redirecting to /bin/systemctl start mariadb.service
[root@localhost ~]# mysq
bash: mysq: command not found...
[root@localhost ~]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.04 sec)

MariaDB [(none)]> create database zabbix;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> use zabbix;
Database changed

MariaDB [zabbix]> create user 'zabbix'@'localhost' identified BY '';
Query OK, 0 rows affected (0.01 sec)


MariaDB [zabbix]> grant all privileges on zabbix.* to zabbix@localhost ;
Query OK, 0 rows affected (0.00 sec)

MariaDB [zabbix]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [zabbix]> quit
Bye


- name: import zabbix db

      mysql_db: login_host=localhost login_user=zabbix login_password= config_file=/etc/my.cnf name=zabbix state=import target=/usr/share/doc/zabbix-server-mysql-4.4.0/create.sql.gz

[root@localhost ~]# rpm -e zabbix-server-pgsql

[root@localhost ~]# service zabbix-server restart

Redirecting to /bin/systemctl restart zabbix-server.service

[root@localhost ~]# 

[root@localhost ~]# telnet  192.168.0.108 10051
Trying 192.168.0.108...
Connected to 192.168.0.108.
Escape character is '^]'.

^CConnection closed by foreign host.


Comments