diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -177,20 +177,48 @@ ### Setup -Vagrant and Virtualbox tools must be installed. On a debian based environment, + +Vagrant tools must be installed. + +``` +apt install vagrant nfs-kernel-server +``` + +Note: `nfs-kernel-server` is needed to export and share the local /tmp/puppet + to the vm + +Multiple provisioners exist. We will focus on 2 for now, virtualbox the default +and libvirt for now (we had an history of using this one in the past). + +#### virtualbox + +On a debian based environment, [a specific debian repository must be configured](https://www.virtualbox.org/wiki/Linux_Downloads): ``` -apt install vagrant virtualbox-6.0 nfs-kernel-server linux-headers-$(uname --kernel-release) +apt install virtualbox-6.0 linux-headers-$(uname --kernel-release) ``` Note: - 2020-09-17 vagrant (buster) is not working with virtualbox 6.1, so we use `virtualbox-6.0` -- `nfs-kernel-server` is needed to export and share the local /tmp/puppet to the - vm - `linux-headers` package is required for the vbox guest additions +#### libvirt + +Already part of debian so: + +``` +apt install vagrant-libvirt +``` + +Note: +Add your user to the libvirt group. + +``` +usermod -a -G libvirt $USER +``` + ### Usage #### Prepare the puppet environment @@ -232,6 +260,7 @@ staging-webapp running (virtualbox) staging-worker0 running (virtualbox) +staging-deposit not created (libvirt) prod-worker01 not created (virtualbox) test poweroff (virtualbox) diff --git a/Vagrantfile b/Vagrantfile --- a/Vagrantfile +++ b/Vagrantfile @@ -12,10 +12,12 @@ "testing" => "vagrant", "location" => "vagrant" } +# used to define the local vm template path +puppet_env_path=ENV["SWH_PUPPET_ENVIRONMENT_HOME"] # local configuration -#$global_debian10_box = "debian10-20201001-0747" -#$global_debian10_box_url = "file:///path/to/packer/builds/swh-debian-10.6-amd64-20201001-0747.box" +$local_debian10_qcow2 = "debian10-20201004-1105" +$local_debian10_qcow2_url = "file://#{puppet_env_path}/packer/builds/swh-debian-10.6-amd64-20201004-1105.qcow2" # http configuration $global_debian10_box = "debian10-20201001-0747" @@ -186,24 +188,25 @@ config.ssh.insert_key = false - config.vm.box = $global_debian10_box - config.vm.box_url = $global_debian10_box_url - config.vm.box_check_update = false + config.vm.box = $local_debian10_qcow2 + config.vm.box_url = $local_debian10_qcow2_url config.vm.hostname = "test.softwareheritage.org" - config.vm.network :private_network, ip: "10.168.100.30", netmask: "255.255.255.0" - config.vm.network :private_network, ip: "10.168.101.30", netmask: "255.255.255.0" + config.vm.box_check_update = false + config.vm.network :private_network, ip: "10.168.98.30", netmask: "255.255.255.0" + config.vm.network :private_network, ip: "10.168.99.30", netmask: "255.255.255.0" config.vm.network "forwarded_port", guest: 10030, host: 22 - config.vm.synced_folder "/tmp/puppet/", "/tmp/puppet", type: 'nfs' + # no need, seems to be done automatically with libvirt + # config.vm.synced_folder "/tmp/puppet/", "/tmp/puppet", type: 'nfs' - config.vm.provider "virtualbox" do |vb| - vb.name = "test" - vb.gui = false - vb.check_guest_additions = false - vb.linked_clone = true - vb.memory = 512 - vb.cpus = 2 + config.vm.provider :libvirt do |provider| + provider.memory = 512 + provider.cpus = 2 + # local test run: https://github.com/vagrant-libvirt/vagrant-libvirt/issues/45 + provider.driver = 'kvm' + provider.uri = 'qemu+unix:///system' end + config.vm.provision "puppet" do |puppet| puppet.environment_path = "#{environment_path}" puppet.environment = "#{environment}" diff --git a/packer/scripts/post-install.sh b/packer/scripts/post-install.sh --- a/packer/scripts/post-install.sh +++ b/packer/scripts/post-install.sh @@ -17,7 +17,7 @@ export DEBIAN_FRONTEND=noninteractive apt-get update -apt-get install -y man wget curl telnet net-tools dnsutils traceroute unbound +apt-get install -y man wget curl telnet net-tools dnsutils traceroute unbound gpg #### # allow vagrant user to sudo to root without password