Automation: Installing Zabbix using Ansible

Automation: Installing Zabbix using Ansible

Zabbix is an open-source monitoring software that can be used to monitor various parameters of IT infrastructure such as servers, network devices, applications, and services. Ansible is an open-source automation tool that can be used to deploy and manage software applications on multiple servers.

In this blog post, we will discuss the steps to install Zabbix on a newly created virtual machine (VM) using Ansible.

Step 1: Create a new VM using virt-clone

We will create a new VM named zap01 by cloning an existing VM named backup. The new VM will be saved as a disk image named zap01.img in the directory /kvm-store.

[root@kvm01 ~]# virt-clone --connect qemu:///system --original backup --name zap01 -f /kvm-store/zap01.img

Step 2: Start the new VM and access it through the console

We will start the new VM and access it through the console.

[root@kvm01 ~]# virsh start zap01

[root@kvm01 ~]# virsh console zap01

Step 3: Configure the new VM

We will configure the new VM by setting its hostname, IP address, disabling SELinux and firewalld, and installing the Puppet agent.

[root@zap01 ~]# hostnamectl set-hostname zap01.darole.org

[root@zap01 ~]# sed -i 's/192.168.2.219/192.168.2.212/g' /etc/sysconfig/network-scripts/ifcfg-eth0

[root@zap01 ~]# sed -i 's/enforcing/disabled/g' /etc/selinux/config

[root@zap01 ~]# systemctl disable firewalld

[root@zap01 ~]# reboot

[root@zap01 ~]# sh puppet-installation.sh

Step 4: Accept the Puppet agent

We will accept the Puppet agent on the Puppet master server.

[root@pup01 ~]# puppetserver ca list

[root@pup01 ~]# puppetserver ca sign --all

Step 5: Check the Puppet connection on the new VM

We will check the Puppet connection on the new VM. Once the connection is established, it will create an Ansible user and keep its authorized key in the home location for password-less login from the Ansible servers.

[root@zap01 ~]# puppet agent -t

Step 6: Execute the Ansible playbook on the Ansible server

We will log in to the Ansible server and execute the Ansible playbook. The playbook will install the Zabbix webserver, EPEL, PHP, MariaDB, Zabbix server, create the database table, and start the Zabbix service.

[ansible@ans01 ~]$ cd zabbix

[ansible@ans01 zabbix]$ ansible-playbook zabbix-installation.yml

[ansible@ans01 zabbix]$ ansible-playbook mariadb-installation.yml

[ansible@ans01 zabbix]$ ansible-playbook create-db-table.yml

[ansible@ans01 zabbix]$ ansible-playbook zabbix-service.yml

Once the playbook is executed successfully, the Zabbix server will be up and running on the new VM, and then we need to preform web site setup.

Refer to below blog and start for step 6. 

https://vallabhdarolelinux.blogspot.com/2023/01/how-to-install-and-configure-zabbix-5.html 

Conclusion

In this blog post, we discussed the steps to install Zabbix on a newly created VM using Ansible.

Github Link for code : 

https://github.com/vdarole/ansible/tree/main/zabbix-5

No comments:

Post a Comment