vagrant_files/zabbix-debian-playground/Vagrantfile

106 lines
4.6 KiB
Ruby
Raw Permalink Normal View History

# -*- 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
2022-10-12 11:51:19 +02:00
apt-get install -y locales
sed -i 's/^# *\(en_US.UTF-8 UTF-8\)/\1/' /etc/locale.gen
2022-10-12 11:51:19 +02:00
locale-gen
echo "export LC_ALL=en_US.UTF-8" >> ~/.bashrc
echo "export LANG=en_US.UTF-8" >> ~/.bashrc
echo "export LANGUAGE=en_US.UTF-8" >> ~/.bashrc
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
2022-10-12 14:11:17 +02:00
apt install -y zabbix-server-mysql zabbix-frontend-php zabbix-nginx-conf zabbix-sql-scripts zabbix-agent2 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
2022-10-12 14:11:17 +02:00
systemctl restart zabbix-server zabbix-agent2 nginx php7.4-fpm
systemctl enable zabbix-server zabbix-agent2 nginx php7.4-fpm
reboot
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
2022-10-12 14:11:17 +02:00
apt install -y zabbix-agent2
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
2022-10-12 14:51:17 +02:00
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-compose
systemctl enable --now containerd docker
2022-10-12 14:11:17 +02:00
sed -i 's/ServerActive=127.0.0.1/ServerActive=192.168.56.2/g' /etc/zabbix/zabbix_agent2.conf
sed -i 's/Hostname=Zabbix server/Hostname=docker/g' /etc/zabbix/zabbix_agent2.conf
systemctl restart zabbix-agent2
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
2022-10-12 14:11:17 +02:00
$WebClient.DownloadFile("https://cdn.zabbix.com/zabbix/binaries/stable/6.0/6.0.9/zabbix_agent2-6.0.9-windows-amd64-openssl.msi","C:\zabbix\zabbix-agent\zabbix-agent2.msi")
Start-Process msiexec.exe -Wait -ArgumentList '/I C:\installers\SQLIO.msi\zabbix-agent2.msi /quiet'
SHELL
end
2022-10-12 16:56:13 +02:00
config.vm.define "pfs" do |pfs|
pfs.vm.box = "xenomii/pfsense-2.6.0"
pfs.vm.hostname = "pfSense"
pfs.vm.network "forwarded_port", guest: 80, host: 8081, host_ip: "127.0.0.1"
pfs.vm.network "forwarded_port", guest: 443, host: 8082, host_ip: "127.0.0.1"
pfs.vm.network "private_network", ip: "192.168.56.5"
pfs.vm.provider "virtualbox" do |vb|
vb.memory = 2048
vb.cpus = 2
end
pfs.vm.provision "shell", inline: <<-SHELL
pkg install pfSense-pkg-zabbix-agent6-1.0.4_12
SHELL
end
end