|
| 1 | +# Copyright 2022 Tobias Anker <tobias.anker@kitsunemimi.moe> |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License") |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# Run host-side script first in "vagrant up"-command |
| 16 | +if ARGV.any? { |arg| arg == "up" } |
| 17 | + puts "Building Docker images before vagrant up..." |
| 18 | + system("./scripts/build_docker_images.sh") or abort("build_docker_images.sh failed, stopping!") |
| 19 | +end |
| 20 | + |
| 21 | +Vagrant.configure("2") do |config| |
| 22 | + # There is no official debian 13 image for vagrant, because of the license-change |
| 23 | + # Used this alternative images instead: https://github.com/alchemy-solutions/vagrant-cloud-images |
| 24 | + config.vm.box = "cloud-image/debian-13" |
| 25 | + |
| 26 | + nodes = { |
| 27 | + "server" => "192.168.56.10", |
| 28 | + "agent1" => "192.168.56.11", |
| 29 | + "agent2" => "192.168.56.12" |
| 30 | + } |
| 31 | + |
| 32 | + nodes.each do |name, ip| |
| 33 | + config.vm.define name do |node| |
| 34 | + # Add three extra disks of 5G each in addition to the root disk for the onsen |
| 35 | + node.vm.provider :libvirt do |libvirt| |
| 36 | + libvirt.storage :file, size: "5G", name: "ainari-#{name}-vdb.qcow2" |
| 37 | + end |
| 38 | + |
| 39 | + node.vm.hostname = name |
| 40 | + node.vm.network "private_network", ip: ip |
| 41 | + node.vm.provider "libvirt" do |vb| |
| 42 | + vb.memory = 4096 |
| 43 | + vb.cpus = 4 |
| 44 | + vb.storage :file, size: 10 |
| 45 | + end |
| 46 | + end |
| 47 | + end |
| 48 | + |
| 49 | + # Run provision.yml for the 'ainari-test' group |
| 50 | + config.vm.provision "ansible" do |ansible| |
| 51 | + ansible.playbook = "testing/vagrant/playbook.yaml" |
| 52 | + ansible.become = true |
| 53 | + |
| 54 | + ansible.extra_vars = { |
| 55 | + ansible_python_interpreter: "/usr/bin/python3" |
| 56 | + } |
| 57 | + # ansible.verbose = "vvv" |
| 58 | + ansible.groups = { |
| 59 | + "k3s_server" => ["server"], |
| 60 | + "k3s_agents" => ["agent1", "agent2"] |
| 61 | + } |
| 62 | + end |
| 63 | +end |
0 commit comments