diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -177,20 +177,53 @@ ### 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 libvirt-daemon-system qemu-kvm vagrant=2.2.3+dfsg-1 vagrant-libvirt +``` + +Note: +- Use the vagrant packaged packaged in debian stable (not hashicorp's) +- Add your user to the libvirt group. + +``` +sudo usermod --append --groups libvirt `whoami` +``` + +``` +usermod -a -G libvirt $USER +``` + ### Usage #### Prepare the puppet environment @@ -232,6 +265,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 @@ -13,12 +13,17 @@ "deployment" => "staging", "subnet" => "vagrant" } +# used to define the local vm template path +puppet_env_path=ENV["SWH_PUPPET_ENVIRONMENT_HOME"] # Images configuration $global_debian10_box = "debian10-20201006-0832" $global_debian10_box_url = "https://annex.softwareheritage.org/public/isos/virtualbox/debian/swh-debian-10.6-amd64-20201006-0832.box" # For local tests #$global_debian10_box_url = "file:///path/to/packer/builds/swh-debian-10.6-amd64-20201006-0832.box" +# local configuration +$local_debian10_qcow2 = "debian10-20201004-1105" +$local_debian10_qcow2_url = "file://#{puppet_env_path}/packer/builds/swh-debian-10.6-amd64-20201004-1105.qcow2" Vagrant.configure("2") do |global_config| ################ @@ -223,4 +228,45 @@ puppet.facter = puppet_default_facts end end + + unless Vagrant.has_plugin?("libvirt") + $stderr.puts <<-MSG + vagrant-libvirt plugin is required for this. + To install: `$ sudo apt install vagrant-libvirt +MSG + exit 1 + end + + global_config.vm.define :qemutest do |config| + config.ssh.insert_key = false + + config.vm.box = $local_debian10_qcow2 + config.vm.box_url = $local_debian10_qcow2_url + config.vm.hostname = "test.softwareheritage.org" + 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' + # ssl certificates share + config.vm.synced_folder "vagrant/le_certs", "/etc/puppet/le_certs", type: 'nfs' + + 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' + end + + config.vm.provision "puppet" do |puppet| + puppet.environment_path = "#{environment_path}" + puppet.environment = "#{environment}" + puppet.hiera_config_path = "#{puppet.environment_path}/#{puppet.environment}/hiera.yaml" + puppet.manifest_file = "#{manifest_file}" + puppet.manifests_path = "#{manifests_path}" + puppet.options = "#{puppet_options}" + puppet.facter = puppet_default_facts + end + end end 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