Skip to content
Snippets Groups Projects
Commit d333bd89 authored by Florian Sesser's avatar Florian Sesser
Browse files

Merge branch '87.qemu-local-grid' into upgrade-nixos-to-22.11-and-local-grid

parents 73432ede c583150d
No related tags found
No related merge requests found
...@@ -24,7 +24,6 @@ The system tests are run using this command:: ...@@ -24,7 +24,6 @@ The system tests are run using this command::
$ nix-build --attr system-tests $ nix-build --attr system-tests
The system tests boot QEMU VMs which prevents them from running on CI at this time.
The build requires > 10 GB of disk space, The build requires > 10 GB of disk space,
and the VMs might be timing out on slow or busy machines. and the VMs might be timing out on slow or busy machines.
If you run into timeouts, If you run into timeouts,
......
...@@ -8,14 +8,18 @@ Issues with networking that looked like guest misconfigurations vanished after c ...@@ -8,14 +8,18 @@ Issues with networking that looked like guest misconfigurations vanished after c
This requires `NixOS <https://nixos.org/>`_. This requires `NixOS <https://nixos.org/>`_.
Nix without the OS will not work. Nix without the OS will not work.
Use the local development environment Use the local development environment
````````````````````````````````````` `````````````````````````````````````
0. Add VirtualBox to your NixOs system configuration at ``/etc/nixos/configuration.nix``:: 0. Add to your NixOS system configuration at ``/etc/nixos/configuration.nix`` (and rebuild)::
virtualisation.virtualbox.host.enable = true; # Enable libvirt - likely incompatible with virtualisation.virtualbox!
# Save bytes and build time, optional but recommended: virtualisation.libvirtd.enable = true;
virtualisation.virtualbox.host.headless = true; # Required for LibVirt
security.polkit.enable = true;
# Enable HW acceleration if (nested virtualisation is) available
#boot.kernelModules = [ "kvm-amd" "kvm-intel" ];
1. Enter the morph local grid directory:: 1. Enter the morph local grid directory::
...@@ -27,7 +31,7 @@ Use the local development environment ...@@ -27,7 +31,7 @@ Use the local development environment
3. Build and start the VMs:: 3. Build and start the VMs::
VAGRANT_DEFAULT_PROVIDER=virtualbox vagrant up vagrant up --provider=libvirt
4. Then, add the Vagrant SSH configuration to your user's ``~/.ssh/config`` file:: 4. Then, add the Vagrant SSH configuration to your user's ``~/.ssh/config`` file::
...@@ -35,11 +39,11 @@ Use the local development environment ...@@ -35,11 +39,11 @@ Use the local development environment
Latest Morph honors the ``SSH_CONFIG_FILE`` environment variable (`since 3f90aa88 (March 2020, v 1.5.0) <https://github.com/DBCDK/morph/commit/3f90aa885fac1c29fce9242452fa7c0c505744ef#diff-d155ad793bd62e6ea4c44ba985049ecb13a4f4f32f799791b2bce695a16c0101>`_), so in the future this should get a bit more convenient. Latest Morph honors the ``SSH_CONFIG_FILE`` environment variable (`since 3f90aa88 (March 2020, v 1.5.0) <https://github.com/DBCDK/morph/commit/3f90aa885fac1c29fce9242452fa7c0c505744ef#diff-d155ad793bd62e6ea4c44ba985049ecb13a4f4f32f799791b2bce695a16c0101>`_), so in the future this should get a bit more convenient.
6. Create a ``public-keys/users.nix`` file with your SSH key (see ``public-keys/users.nix.example`` for the format) so you'll be able to log in after deploying the new configuration:: 5. Create a ``public-keys/users.nix`` file with your SSH key (see ``public-keys/users.nix.example`` for the format) so you'll be able to log in after deploying the new configuration::
$EDITOR public-keys/users.nix $EDITOR public-keys/users.nix
7. Then, build and deploy our software to the Vagrant VMs:: 6. Then, build and deploy our software to the Vagrant VMs::
morph build grid.nix morph build grid.nix
morph push grid.nix morph push grid.nix
......
# -*- mode: ruby -*- # -*- mode: ruby -*-
# vi: set ft=ruby : # vi: set ft=ruby :
# This Vagrantfile worked for Florian Sesser using Vagrant 2.2.16dev and # This Vagrantfile worked for Florian Sesser using Vagrant 2.2.19 and
# the VirtualBox Hypervisor. Earlier Vagrant and LibVirt did not work. # the LibVirt with QEmu Hypervisor. Earlier Vagrant and VirtualBox did worked too.
# Get a dedicated LibVirt pool name or use default one
pool_name = ENV.has_key?('POOL_NAME') ? ENV['POOL_NAME'] : 'default'
# For instance, one could create such pool beforehand as follows:
# export POOL_NAME=morph_local_$(id -un)
# POOL_PATH="/path/to/your/storage"
# mkdir -p "${POOL_PATH}"
# sudo virsh pool-define-as ${POOL_NAME} --type dir --target "${POOL_PATH}"
# sudo virsh pool-autostart ${POOL_NAME}
# sudo virsh pool-start ${POOL_NAME}
Vagrant.configure("2") do |config| Vagrant.configure("2") do |config|
# For a complete reference, please see the online documentation at # For a complete reference, please see the online documentation at
# https://docs.vagrantup.com. # https://docs.vagrantup.com.
config.vm.define "payments.localdev" do |config| # Select the base image
config.vm.hostname = "payments"
config.vm.box = "esselius/nixos" config.vm.box = "esselius/nixos"
config.vm.box_version = "20.09" config.vm.box_version = "20.09"
config.vm.box_check_update = false config.vm.box_check_update = false
# No need to sync the working dir. with the guest boxess
# Better use SFTP to transfer
config.vm.synced_folder ".", "/vagrant", disabled: true
# Tune LibVirt/QEmu guests
config.vm.provider :libvirt do |domain|
# The default of one CPU should work
# Increase to speed up boot/push/deploy
# domain.cpus = 1
# To use the self-updating deployment system you need more memory. Giving # To use the self-updating deployment system you need more memory. Giving
# all of the VMs enough memory for this is rather taxing, though, and the # all of the VMs enough memory for this is rather taxing, though, and the
# self-updating deployment system is not particularly useful for local # self-updating deployment system is not particularly useful for local
# dev. But should you want to: # dev. But should you want to:
# #
# config.vm.provider "virtualbox" do |v| # domain.memory = 4096
# v.memory = 4096 #
# end # Meanwhile, 1024 was apparently the default with VirtualBox
domain.memory = 1024
# Assign a static IP address inside the VirtualBox host-only (Vagrant # Using a specific pool may help to manage the disk space
domain.storage_pool_name = pool_name
domain.snapshot_pool_name = pool_name
# No need of graphics - better use serial
domain.graphics_type = "none"
domain.video_type = "none"
end
config.vm.define "payments.localdev" do |config|
config.vm.hostname = "payments"
# Assign a static IP address inside the box host-only (Vagrant
# calls it "private") network. The address must be in the range # calls it "private") network. The address must be in the range
# VirtualBox allows. # VirtualBox allows.
# https://www.virtualbox.org/manual/ch06.html#network_hostonly says some # https://www.virtualbox.org/manual/ch06.html#network_hostonly says some
...@@ -37,31 +69,25 @@ Vagrant.configure("2") do |config| ...@@ -37,31 +69,25 @@ Vagrant.configure("2") do |config|
config.vm.define "storage1.localdev" do |config| config.vm.define "storage1.localdev" do |config|
config.vm.hostname = "storage1" config.vm.hostname = "storage1"
config.vm.box = "esselius/nixos"
config.vm.box_version = "20.09"
config.vm.box_check_update = false
config.vm.network "private_network", ip: "192.168.56.22" config.vm.network "private_network", ip: "192.168.56.22"
end end
config.vm.define "storage2.localdev" do |config| config.vm.define "storage2.localdev" do |config|
config.vm.hostname = "storage2" config.vm.hostname = "storage2"
config.vm.box = "esselius/nixos"
config.vm.box_version = "20.09"
config.vm.box_check_update = false
config.vm.network "private_network", ip: "192.168.56.23" config.vm.network "private_network", ip: "192.168.56.23"
end end
config.vm.define "monitoring.localdev" do |config| config.vm.define "monitoring.localdev" do |config|
config.vm.hostname = "monitoring" config.vm.hostname = "monitoring"
config.vm.box = "esselius/nixos"
config.vm.box_version = "20.09"
config.vm.box_check_update = false
config.vm.network "private_network", ip: "192.168.56.24" config.vm.network "private_network", ip: "192.168.56.24"
end end
# To make the VMs assign the static IPs to the network interfaces we need a rebuild: # To make the VMs assign the static IPs to the network interfaces we need a rebuild:
config.vm.provision "shell", inline: "echo '{nix.settings.trusted-users = [ \"@wheel\" \"root\" \"vagrant\" ];}' > /etc/nixos/custom-configuration.nix" config.vm.provision "shell",
inline: "echo '{ nix.trustedUsers = [ \"@wheel\" \"root\" \"vagrant\" ]; boot.kernelParams = [ \"console=tty0\" \"console=ttyS0,115200\" ]; }' > /etc/nixos/custom-configuration.nix"
config.vm.provision "shell", inline: "nixos-rebuild switch" config.vm.provision "shell", inline: "nixos-rebuild switch"
config.vm.provision "shell", inline: "systemctl stop firewall.service"
config.vm.provision "shell", inline: "systemctl start serial-getty@ttyS0.service"
config.trigger.after :up do |trigger| config.trigger.after :up do |trigger|
trigger.info = "Hostname and IP address this host actually uses:" trigger.info = "Hostname and IP address this host actually uses:"
......
...@@ -15,18 +15,19 @@ ...@@ -15,18 +15,19 @@
}; };
config = { config = {
virtualisation.virtualbox.guest.enable = true; services.qemuGuest.enable = true;
boot.loader.grub.device = "/dev/sda"; boot.loader.grub.device = "/dev/vda";
boot.initrd.availableKernelModules = [ "ata_piix" "sd_mod" "sr_mod" ]; boot.initrd.availableKernelModules = [ "ata_piix" "virtio_pci" "virtio_blk" "sd_mod" "sr_mod" ];
boot.kernel.sysctl = { "vm.swappiness" = 0; }; boot.kernel.sysctl = { "vm.swappiness" = 0; };
boot.kernelParams = [ "console=tty0" "console=ttyS0,115200" ];
# remove the fsck that runs at startup. It will always fail to run, stopping # remove the fsck that runs at startup. It will always fail to run, stopping
# your boot until you press *. # your boot until you press *.
boot.initrd.checkJournalingFS = false; boot.initrd.checkJournalingFS = false;
networking.interfaces.enp0s8.ipv4.addresses = [{ networking.interfaces.ens5.ipv4.addresses = [{
address = config.grid.publicIPv4; address = config.grid.publicIPv4;
prefixLength = 24; prefixLength = 24;
}]; }];
...@@ -47,7 +48,7 @@ ...@@ -47,7 +48,7 @@
fileSystems."/storage" = { fsType = "tmpfs"; }; fileSystems."/storage" = { fsType = "tmpfs"; };
fileSystems."/" = fileSystems."/" =
{ device = "/dev/sda1"; { device = "/dev/vda1";
fsType = "ext4"; fsType = "ext4";
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment