ansible-role-k3s/tests/Vagrantfile
2019-03-09 20:54:44 +00:00

72 lines
2.1 KiB
Ruby

# -*- mode: ruby -*-
# vi: set ft=ruby :
$centos_provision = <<SCRIPT
if [ ! -f .vagrant_provision ] ; then
echo "Installing dependencies ..."
sudo yum clean all > /dev/null 2>&1 && echo "[OK] Cleanup YUM."
sudo yum makecache > /dev/null 2>&1 && echo "[OK] Create YUM cache."
sudo yum install python libselinux-python -y -q > /dev/null 2>&1 && \
echo "[OK] Installing Python."
touch .vagrant_provision
else
echo "Already Provisioned."
fi
SCRIPT
$debian_provision = <<SCRIPT
if [ ! -f .vagrant_provision ] ; then
echo "Installing dependencies ..."
sudo apt update > /dev/null 2>&1 && echo "[OK] Update APT cache."
sudo apt-get install python -y > /dev/null 2>&1 && \
echo "[OK] Installing Python."
touch .vagrant_provision
else
echo "Already Provisioned."
fi
SCRIPT
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "node1" do |node1|
node1.vm.box = "centos/7"
node1.vm.hostname = "k3s-node01"
node1.vm.network "private_network", ip: "172.16.3.30"
node1.vm.provider "virtualbox" do |vb|
vb.name = "k3s - node1"
vb.memory = 512
end
node1.vm.provision "shell", inline: $centos_provision
end
config.vm.define "node2" do |node2|
node2.vm.box = "debian/stretch64"
node2.vm.hostname = "k3s-node02"
node2.vm.network "private_network", ip: "172.16.3.31"
node2.vm.provider "virtualbox" do |vb|
vb.name = "k3s - node2"
vb.memory = 512
end
node2.vm.provision "shell", inline: $debian_provision
end
config.vm.define "node3" do |node3|
node3.vm.box = "ubuntu/bionic64"
node3.vm.hostname = "k3s-node03"
node3.vm.network "private_network", ip: "172.16.3.32"
node3.vm.provider "virtualbox" do |vb|
vb.name = "k3s - node3"
vb.memory = 512
end
node3.vm.provision "shell", inline: $debian_provision
node3.vm.provision "ansible" do |a|
a.limit = "all"
a.config_file = "ansible.cfg"
a.inventory_path = "inventory.yml"
a.playbook = "test.yml"
a.verbose = "v"
end
end
end