1
1
ansible_vagrant/Vagrantfile

220 lines
6.3 KiB
Ruby
Raw Normal View History

2023-06-27 10:21:05 +02:00
Vagrant.configure("2") do |config|
2023-06-27 19:27:11 +02:00
config.vm.define "vm1" do |vm1|
vm1.vm.network "private_network", ip: "192.168.56.2"
2024-04-17 22:59:06 +02:00
vm1.vm.box = "debian/bullseye64"
2023-06-27 19:27:11 +02:00
vm1.vm.provider "virtualbox" do |vb|
2023-07-30 21:26:21 +02:00
vb.memory = "512"
2023-07-30 18:49:56 +02:00
vb.cpus = 1
2023-06-27 19:27:11 +02:00
end
vm1.vm.synced_folder ".", "/vagrant", disabled: true
2023-06-27 19:27:11 +02:00
vm1.vm.provision "shell", inline: <<-SHELL
2024-04-17 22:59:06 +02:00
apt-get update && apt-get upgrade -y
apt-get clean
apt-get install mc apache2 -y
2023-06-27 19:27:11 +02:00
echo "vm1" > /etc/hostname
hostname -F /etc/hostname
2023-07-31 10:32:10 +02:00
echo "192.168.56.2 vm1" >> /etc/hosts
2023-08-01 10:00:08 +02:00
timedatectl set-timezone Europe/Budapest
2023-06-27 19:27:11 +02:00
SHELL
end
config.vm.define "vm2" do |vm2|
vm2.vm.network "private_network", ip: "192.168.56.3"
vm2.vm.box = "almalinux/8"
vm2.vm.provider "virtualbox" do |vb|
2023-07-31 19:51:07 +02:00
vb.memory = "768"
2023-07-30 18:49:56 +02:00
vb.cpus = 1
2023-06-27 19:27:11 +02:00
end
vm2.vm.synced_folder ".", "/vagrant", disabled: true
2023-06-27 19:27:11 +02:00
vm2.vm.provision "shell", inline: <<-SHELL
dnf install mc epel-release httpd net-tools -y
dnf update -y
systemctl enable --now httpd
echo "vm2" > /etc/hostname
hostname -F /etc/hostname
2023-07-31 10:32:10 +02:00
echo "192.168.56.3 vm2" >> /etc/hosts
2023-08-01 10:00:08 +02:00
timedatectl set-timezone Europe/Budapest
2023-06-27 19:27:11 +02:00
SHELL
end
config.vm.define "vm3" do |vm3|
vm3.vm.network "private_network", ip: "192.168.56.4"
vm3.vm.box = "ubuntu/jammy64"
vm3.vm.provider "virtualbox" do |vb|
2023-07-30 21:26:21 +02:00
vb.memory = "512"
2023-07-30 18:49:56 +02:00
vb.cpus = 1
2023-06-27 19:27:11 +02:00
end
vm3.vm.synced_folder ".", "/vagrant", disabled: true
2023-06-27 19:27:11 +02:00
vm3.vm.provision "shell", inline: <<-SHELL
apt-get update && apt-get upgrade -y
apt-get install mc apache2 -y
apt-get clean
echo "vm3" > /etc/hostname
hostname -F /etc/hostname
2023-07-31 10:32:10 +02:00
echo "192.168.56.4 vm3" >> /etc/hosts
2023-08-01 10:00:08 +02:00
timedatectl set-timezone Europe/Budapest
2023-06-27 19:27:11 +02:00
SHELL
end
config.vm.define "vm4" do |vm4|
2024-04-17 22:59:06 +02:00
vm4.vm.network "private_network", ip: "192.168.57.5"
2023-08-01 10:01:30 +02:00
vm4.vm.box = "debian/bookworm64"
2023-06-27 19:27:11 +02:00
vm4.vm.provider "virtualbox" do |vb|
2023-07-30 21:26:21 +02:00
vb.memory = "512"
2023-07-30 18:49:56 +02:00
vb.cpus = 1
2023-06-27 19:27:11 +02:00
end
vm4.vm.synced_folder ".", "/vagrant", disabled: true
2023-06-27 19:27:11 +02:00
vm4.vm.provision "shell", inline: <<-SHELL
apt-get update && apt-get upgrade -y
apt-get clean
apt-get install mc apache2 -y
echo "vm4" > /etc/hostname
hostname -F /etc/hostname
2024-04-17 22:59:06 +02:00
echo "192.168.57.5 vm4" >> /etc/hosts
2023-08-01 10:00:08 +02:00
timedatectl set-timezone Europe/Budapest
2023-06-27 19:27:11 +02:00
SHELL
end
2023-07-30 21:26:21 +02:00
config.vm.define "zbxsrv" do |zbxsrv|
zbxsrv.vm.network "private_network", ip: "192.168.56.6"
zbxsrv.vm.box = "almalinux/9"
2023-07-30 21:26:21 +02:00
zbxsrv.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
2023-07-30 21:26:21 +02:00
vb.cpus = 1
end
zbxsrv.vm.synced_folder ".", "/vagrant", disabled: true
2023-07-30 21:26:21 +02:00
zbxsrv.vm.provision "shell", inline: <<-SHELL
yum install mc net-tools -y
2023-07-30 21:26:21 +02:00
yum update -y
echo "zbxsrv" > /etc/hostname
hostname -F /etc/hostname
2023-07-31 10:32:10 +02:00
echo "192.168.56.6 zbxsrv" >> /etc/hosts
2023-08-01 10:00:08 +02:00
timedatectl set-timezone Europe/Budapest
mkdir -p /home/vagrant/docker/zabbix-server
cat > /home/vagrant/docker/zabbix-server/docker-compose.yml << EOL
volumes:
DB:
services:
zabbix-server:
container_name: zabbix-server
image: zabbix/zabbix-server-mysql:alpine-6.4-latest
volumes:
- /etc/localtime:/etc/localtime:ro
2024-04-17 22:59:06 +02:00
- ./ssh_keys:/var/lib/zabbix/ssh_keys
ports:
- 10051:10051
restart: always
environment:
- DB_SERVER_HOST=zabbix-db
- DB_SERVER_PORT=3306
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=P@G*LCxUAU96L5oq
- ZBX_STARTPINGERS=3
- ZBX_LISTENPORT=10051
networks:
customnetwork:
ipv4_address: 192.168.151.2
zabbix-web:
container_name: zabbix-web
image: zabbix/zabbix-web-apache-mysql:alpine-6.4-latest
volumes:
- /etc/localtime:/etc/localtime:ro
ports:
- 888:8080
restart: always
environment:
- DB_SERVER_HOST=zabbix-db
- DB_SERVER_PORT=3306
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=P@G*LCxUAU96L5oq
- ZBX_SERVER_HOST=zabbix-server
- ZBX_SERVER_PORT=10051
- ZBX_SERVER_NAME=zbxsrv
- PHP_TZ=Europe/Budapest
networks:
customnetwork:
ipv4_address: 192.168.151.3
zabbix-db:
container_name: zabbix-db
image: mariadb:10.6
volumes:
- DB:/var/lib/mysql
- /etc/localtime:/etc/localtime:ro
command: mysqld --collation-server=utf8mb4_bin
restart: always
environment:
- MYSQL_ROOT_PASSWORD=xQdr0iORWI8ZEY1F
- MYSQL_DATABASE=zabbix
- MYSQL_USER=zabbix
- MYSQL_PASSWORD=P@G*LCxUAU96L5oq
networks:
customnetwork:
ipv4_address: 192.168.151.4
networks:
customnetwork:
ipam:
config:
- subnet: 192.168.151.0/24
EOL
2023-07-30 21:26:21 +02:00
SHELL
end
2024-04-17 22:59:06 +02:00
config.vm.define "proxy1" do |proxy1|
proxy1.vm.network "private_network", ip: "192.168.57.6"
proxy1.vm.box = "almalinux/9"
proxy1.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
vb.cpus = 1
end
proxy1.vm.synced_folder ".", "/vagrant", disabled: true
proxy1.vm.provision "shell", inline: <<-SHELL
yum install mc net-tools -y
yum update -y
echo "proxy1" > /etc/hostname
hostname -F /etc/hostname
echo "192.168.57.6 proxy1" >> /etc/hosts
timedatectl set-timezone Europe/Budapest
mkdir -p /home/vagrant/docker/zabbix-proxy
mkdir -p /var/lib/docker/volumes/zabbix-proxy_ZBXPROXY_SECRETS/_data
cat > /var/lib/docker/volumes/zabbix-proxy_ZBXPROXY_SECRETS/_data/zabbix.psk << EOL
977b74008c40fed130a410074df64a4fafd7244b64e163ec86a77e0e49323dbd
EOL
cat > /home/vagrant/docker/zabbix-proxy/docker-compose.yml << EOL
volumes:
ZBXPROXY_DB:
ZBXPROXY_SNMPTRAPS:
ZBXPROXY_SECRETS:
services:
zabbix-proxy:
container_name: zabbix-proxy
image: zabbix/zabbix-proxy-sqlite3:alpine-6.4-latest
volumes:
- /etc/localtime:/etc/localtime:ro
- ZBXPROXY_DB:/var/lib/zabbix/db_data
- ZBXPROXY_SNMPTRAPS:/var/lib/zabbix/snmptraps
- ZBXPROXY_SECRETS:/var/lib/zabbix/enc
ports:
- 10051:10051
restart: always
environment:
- ZBX_SERVER_HOST=192.168.56.6
- ZBX_SERVER_PORT=10051
- ZBX_HOSTNAME=proxy1
- ZBX_CONFIGFREQUENCY=60
- ZBX_TLSCONNECT=psk
- ZBX_TLSPSKFILE=/var/lib/zabbix/enc/zabbix.psk
- ZBX_TLSPSKIDENTITY=proxy1
EOL
SHELL
end
2023-06-27 10:21:05 +02:00
end