mirror of
https://github.com/PyratLabs/ansible-role-k3s
synced 2024-11-10 07:23:30 +01:00
96 lines
2.8 KiB
Ruby
96 lines
2.8 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
|
|
|
|
$opensuse_provision = <<SCRIPT
|
|
if [ ! -f .vagrant_provision ] ; then
|
|
echo "Installing dependencies ..."
|
|
sudo zypper refresh > /dev/null 2>&1 && echo "[OK] Update Zypper cache."
|
|
sudo zypper install -y python python-xml > /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/buster64"
|
|
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 = "bento/opensuse-leap-15.1"
|
|
node3.vm.hostname = "k3s-node03"
|
|
node3.vm.network "private_network", ip: "172.16.3.32"
|
|
node3.vm.synced_folder ".", "/vagrant", disabled: true
|
|
|
|
node3.vm.provider "virtualbox" do |vb|
|
|
vb.name = "k3s - node3"
|
|
vb.memory = 512
|
|
end
|
|
node3.vm.provision "shell", inline: $opensuse_provision
|
|
end
|
|
|
|
config.vm.define "node4" do |node4|
|
|
node4.vm.box = "ubuntu/bionic64"
|
|
node4.vm.hostname = "k3s-node04"
|
|
node4.vm.network "private_network", ip: "172.16.3.33"
|
|
node4.vm.provider "virtualbox" do |vb|
|
|
vb.name = "k3s - node4"
|
|
vb.memory = 512
|
|
end
|
|
node4.vm.provision "shell", inline: $debian_provision
|
|
node4.vm.provision "ansible" do |a|
|
|
a.limit = "all"
|
|
a.config_file = "ansible.cfg"
|
|
a.inventory_path = "inventory.yml"
|
|
a.playbook = "test.yml"
|
|
a.verbose = "vv"
|
|
end
|
|
end
|
|
end
|