diff options
Diffstat (limited to 'vagrant/templates/Vagrantfile.j2')
-rw-r--r-- | vagrant/templates/Vagrantfile.j2 | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/vagrant/templates/Vagrantfile.j2 b/vagrant/templates/Vagrantfile.j2 new file mode 100644 index 0000000..1ef3a53 --- /dev/null +++ b/vagrant/templates/Vagrantfile.j2 @@ -0,0 +1,97 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : +# + +NODES = 2 +DISKS = 3 +NODE_RAM = 1024 +NODE_CPUS = 2 +PRIVATE_NETWORK_BASE = "192.168.122" +PUBLIC_NETWORK_BASE = "192.168.123" +#LIBVIRT_STORAGE_POOL = "data" + +SETUP_IP = "#{PRIVATE_NETWORK_BASE}.200" +CLIENT_IP = "#{PUBLIC_NETWORK_BASE}.5" + +Vagrant.configure("2") do |config| + config.ssh.insert_key = false + config.vm.provider :libvirt do |v,override| + override.vm.box = "{{ distro.vagrant_image }}" + override.vm.synced_folder '.', '/vagrant', disabled: true + + # We can not use qemu_use_session universally. + # - On Fedora 31, it is required for me to start. + # - But on centos7, it must not be set. + # The best workarount I found is to put this setting into + # your ~/.vagrant.d/Vagrantfile like so: + # ``` + # Vagrant.configure("2") do |config| + # config.vm.provider :libvirt do |libvirt| + # libvirt.qemu_use_session = false + # end + # end + # ``` + #v.qemu_use_session = false + + # change cpu mode to passthrough as workaround for problems in the ci, + # refer to bugs: + # https://bugzilla.redhat.com/show_bug.cgi?id=1467599 + # https://bugzilla.redhat.com/show_bug.cgi?id=1386223#c10 + # vagrant-libvirt/vagrant-libvirt#667 + # taken from: + # https://github.com/heketi/heketi/pull/1008 + v.cpu_mode = 'host-passthrough' + end + + (0..NODES-1).each do |i| + config.vm.define "storage#{i}" do |storage| + storage.vm.hostname = "storage#{i}" + storage.vm.network :private_network, ip: "#{PRIVATE_NETWORK_BASE}.10#{i}" + storage.vm.network :private_network, ip: "#{PUBLIC_NETWORK_BASE}.10#{i}" + (0..DISKS-1).each do |d| + storage.vm.provider :virtualbox do |vb| + vb.customize [ "createhd", "--filename", "disk-#{i}#{d}.vdi", "--size", 10*1024 ] + vb.customize [ "storageattach", :id, "--storagectl", "SATA Controller", "--port", 3+d, "--device", 0, "--type", "hdd", "--medium", "disk-#{i}#{d}.vdi" ] + vb.memory = NODE_RAM + vb.cpus = NODE_CPUS + end + + driverletters = ('b'..'z').to_a + storage.vm.provider :libvirt do |lv| + if defined?(LIBVIRT_STORAGE_POOL) + lv.storage_pool_name = "#{LIBVIRT_STORAGE_POOL}" + end + lv.storage :file, :device => "vd#{driverletters[d]}", :path => "disk-#{i}#{d}.disk", :size => '10G' + lv.memory = NODE_RAM + lv.cpus = NODE_CPUS + end + end + end + end + + + # Client vm: + # This VM will connect to the cluster over the public ip addresses + config.vm.define "client1" do |setup| + setup.vm.hostname = "client1" + setup.vm.network :private_network, ip: "#{CLIENT_IP}" + end + + # setup vm: + # We will runn all our setup playbooks from there. + config.vm.define "setup" do |setup| + setup.vm.hostname = "setup" + setup.vm.network :private_network, ip: "#{SETUP_IP}" + # Run a no-op playbook to create the inventory file. + # Based on that, one can run ansible without vagrant. + setup.vm.provision "no-op", type:'ansible' do |ansible| + ansible.playbook = "no-op-playbook.yml" + ansible.groups = { + "admin" => [ "setup" ], + "clients" => [ "client1" ], + "cluster" => (0..NODES-1).map { |i| "storage#{i}" } + } + end + end + +end |