82 lines
3.7 KiB
Ruby
82 lines
3.7 KiB
Ruby
# -*- mode: ruby -*-
|
|
# vi: set ft=ruby :
|
|
Vagrant.configure("2") do |config|
|
|
|
|
config.vm.define "zabbix" do |zabbix|
|
|
zabbix.vm.box = "debian/bullseye64"
|
|
zabbix.vm.network "forwarded_port", guest: 8080, host: 8080, host_ip: "127.0.0.1"
|
|
zabbix.vm.network "private_network", ip: "192.168.56.2"
|
|
zabbix.vm.hostname = "zabbix"
|
|
zabbix.vm.provider "virtualbox" do |vb|
|
|
vb.memory = 4096
|
|
vb.cpus = 2
|
|
end
|
|
|
|
zabbix.vm.provision "shell", inline: <<-SHELL
|
|
apt update
|
|
apt install -y curl
|
|
curl -o /tmp/zabbix_6.0.deb https://repo.zabbix.com/zabbix/6.0/debian/pool/main/z/zabbix-release/zabbix-release_6.0-4%2Bdebian11_all.deb
|
|
dpkg -i /tmp/zabbix_6.0.deb
|
|
apt update -y
|
|
apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent mariadb-server mariadb-client nginx
|
|
systemctl enable --now mysql
|
|
mysql -uroot -e 'create database zabbix character set utf8mb4 collate utf8mb4_bin'
|
|
mysql -uroot -e 'create user zabbix@localhost identified by "eattherich"'
|
|
mysql -uroot -e 'grant all privileges on zabbix.* to zabbix@localhost'
|
|
mysql -uroot -e 'set global log_bin_trust_function_creators = 1'
|
|
zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -peattherich -D zabbix
|
|
mysql -uroot -e 'set global log_bin_trust_function_creators = 0;'
|
|
echo 'DBPassword=eattherich' >> /etc/zabbix/zabbix_server.conf
|
|
sed -i 's/#//g' /etc/zabbix/nginx.conf
|
|
sed -i 's/example.com/zabbix.local/g' /etc/zabbix/nginx.conf
|
|
systemctl restart zabbix-server zabbix-agent nginx php7.4-fpm
|
|
SHELL
|
|
end
|
|
|
|
config.vm.define "docker" do |docker|
|
|
docker.vm.box = "debian/bullseye64"
|
|
docker.vm.hostname = "docker"
|
|
docker.vm.network "private_network", ip: "192.168.56.3"
|
|
docker.vm.provider "virtualbox" do |vb|
|
|
vb.memory = 1024
|
|
vb.cpus = 1
|
|
end
|
|
|
|
docker.vm.provision "shell", inline: <<-SHELL
|
|
apt update
|
|
apt install -y curl
|
|
curl -o /tmp/zabbix_6.0.deb https://repo.zabbix.com/zabbix/6.0/debian/pool/main/z/zabbix-release/zabbix-release_6.0-4%2Bdebian11_all.deb
|
|
dpkg -i /tmp/zabbix_6.0.deb
|
|
apt update -y
|
|
apt install -y zabbix-agent
|
|
apt install -y ca-certificates curl gnupg lsb-release
|
|
mkdir -p /etc/apt/keyrings
|
|
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
echo \
|
|
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
|
|
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
|
apt update
|
|
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
|
systemctl enable --now containerd docker
|
|
sed -i 's/ServerActive=127.0.0.1/ServerActive=192.168.56.2/g' /etc/zabbix/zabbix_agentd.conf
|
|
sed -i 's/Hostname=Zabbix server/Hostname=docker/g' /etc/zabbix/zabbix_agentd.conf
|
|
systemctl restart zabbix-agent
|
|
SHELL
|
|
end
|
|
|
|
config.vm.define "windows" do |windows|
|
|
windows.vm.box = "gusztavvargadr/windows-server"
|
|
windows.vm.hostname = "windows-server"
|
|
windows.vm.network "private_network", ip: "192.168.56.4"
|
|
windows.vm.provider "virtualbox" do |vb|
|
|
vb.memory = 2048
|
|
vb.cpus = 2
|
|
end
|
|
windows.vm.provision "shell", inline: <<-SHELL
|
|
$WebClient = New-Object System.Net.WebClient
|
|
$WebClient.DownloadFile("https://cdn.zabbix.com/zabbix/binaries/stable/6.0/6.0.9/zabbix_agent-6.0.9-windows-amd64-openssl.msi","C:\zabbix\zabbix-agent\zabbix-agent.msi")
|
|
Start-Process msiexec.exe -Wait -ArgumentList '/I C:\installers\SQLIO.msi\zabbix-agent.msi /quiet'
|
|
SHELL
|
|
end
|
|
end
|