at master 1.2 kB view raw
1{ pkgs, lib, ... }: 2{ 3 name = "containers-hosts"; 4 meta = { 5 maintainers = with lib.maintainers; [ montag451 ]; 6 }; 7 8 nodes.machine = 9 { lib, ... }: 10 { 11 virtualisation.vlans = [ ]; 12 13 networking.bridges.br0.interfaces = [ ]; 14 networking.interfaces.br0.ipv4.addresses = [ 15 { 16 address = "10.11.0.254"; 17 prefixLength = 24; 18 } 19 ]; 20 21 # Force /etc/hosts to be the only source for host name resolution 22 environment.etc."nsswitch.conf".text = lib.mkForce '' 23 hosts: files 24 ''; 25 26 containers.simple = { 27 autoStart = true; 28 privateNetwork = true; 29 localAddress = "10.10.0.1"; 30 hostAddress = "10.10.0.254"; 31 32 config = { }; 33 }; 34 35 containers.netmask = { 36 autoStart = true; 37 privateNetwork = true; 38 hostBridge = "br0"; 39 localAddress = "10.11.0.1/24"; 40 41 config = { }; 42 }; 43 }; 44 45 testScript = '' 46 start_all() 47 machine.wait_for_unit("default.target") 48 49 with subtest("Ping the containers using the entries added in /etc/hosts"): 50 for host in "simple.containers", "netmask.containers": 51 machine.succeed(f"ping -n -c 1 {host}") 52 ''; 53}