diff --git a/README.md b/README.md index c2bebcf..a15044e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # vagrant -le 2023-01-19 +le 2023-01-29 Ce dépôt héberge des **Vagrantfile** dont + * **dns** : Vagrantfile pour 2 serveurs **Bind9** (1 maitre et un esclave), tests **goss** chainés * **docker** * **docker-wordpress** * **docker-glpi** diff --git a/dns/Vagrantfile b/dns/Vagrantfile new file mode 100644 index 0000000..6db2aef --- /dev/null +++ b/dns/Vagrantfile @@ -0,0 +1,53 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant.configure("2") do |config| + # Base VM OS configuration. + config.vm.box = "debian/bullseye64" + config.ssh.insert_key = false + config.vm.synced_folder '.', '/vagrant', disabled: true + + # General VirtualBox VM configuration. + config.vm.provider :virtualbox do |v| + v.memory = 512 + v.cpus = 1 + v.linked_clone = true + v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] + v.customize ["modifyvm", :id, "--ioapic", "on"] + end + + # srv1 master. + config.vm.define "srv1" do |srv1| + srv1.vm.hostname = "srv1" + srv1.vm.network :private_network, ip: "192.168.56.10" + srv1.vm.provision "shell", + inline: "sudo apt-get update ; sudo apt-get install -y vim curl wget" + srv1.vm.provision "shell", path: "provision/setup-master.sh" + end + + + # srv2 slave. + config.vm.define "srv2" do |srv2| + srv2.vm.hostname = "srv2" + srv2.vm.network :private_network, ip: "192.168.56.11" + srv2.vm.provision "shell", + inline: "sudo apt-get update ; sudo apt-get install -y vim curl wget" + srv2.vm.provision "shell", path: "provision/setup-slave.sh" + end + + # cli. + config.vm.define "cli" do |cli| + cli.vm.hostname = "cli" + cli.vm.network :private_network, ip: "192.168.56.30" + cli.vm.provider :virtualbox do |v| + v.customize ["modifyvm", :id, "--memory", 512] + end + cli.vm.provision "shell", + inline: "sudo apt-get update ; sudo apt-get install -y vim curl wget" + cli.vm.provision "ansible" do |ansible| + ansible.playbook = "provision/setup-cli.sh" + end + end + +end + diff --git a/dns/provision/setup-master.sh b/dns/provision/setup-master.sh new file mode 100644 index 0000000..dae269b --- /dev/null +++ b/dns/provision/setup-master.sh @@ -0,0 +1,28 @@ +#!/bin/bash +set -eu + +mondomaine=domaine.lan +apt-get install -y bind9 bind9-doc bind9-host +wget -nc https://gitea.lyc-lecastel.fr/gadmin/vagrant/raw/branch/main/divers/bind/mkzone +bash mkzone "${mondomaine}" +cp db.${mondomaine}* /etc/bind +cp named.conf.local /etc/bind +sudo named-checkconf /etc/bind/named.conf +sudo named-checkzone "${mondomaine}" "/etc/bind/db.${mondomaine}" +sudo systemctl restart bind9 +host srv1 +host srv2 +host -t soa "${mondomaine}" +host -l "${mondomaine}" +curl -fsSL https://goss.rocks/install |sh +goss add command "host ${mondomaine}" +goss add command "host -t soa ${mondomaine}" +goss add command "host -t ns ${mondomaine}" +goss add command "host srv1.${mondomaine}" +goss add command "host srv1" +goss add command "host www" +goss add command "host srv2.${mondomaine}" +goss add command "host srv2" +goss add command "host 192.168.56.10" +goss add command "host 192.168.56.11" +goss v -f tap diff --git a/dns/provision/setup-slave.sh b/dns/provision/setup-slave.sh new file mode 100644 index 0000000..26de306 --- /dev/null +++ b/dns/provision/setup-slave.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -eu + +mondomaine=domaine.lan +apt-get install -y bind9 bind9-doc bind9-host +wget -nc https://gitea.lyc-lecastel.fr/gadmin/vagrant/raw/branch/main/divers/bind/mkzone +bash mkzone -s "${mondomaine}" +cp named.conf.local /etc/bind +sudo named-checkconf /etc/bind/named.conf +sudo named-checkzone "${mondomaine}" "/etc/bind/db.${mondomaine}" +sudo systemctl restart bind9 +host srv1 +host srv2 +host -t soa "${mondomaine}" +host -l "${mondomaine}"