at 25.11-pre 1.3 kB view raw
1# This test verifies that the amazon-init service can treat the `user-data` ec2 2# metadata file as a shell script. If amazon-init detects that `user-data` is a 3# script (based on the presence of the shebang #! line) it executes it and 4# exits. 5# Note that other tests verify that amazon-init can treat user-data as a nixos 6# configuration expression. 7 8{ 9 lib, 10 ... 11}: 12 13{ 14 name = "amazon-init"; 15 meta = with lib.maintainers; { 16 maintainers = [ urbas ]; 17 }; 18 nodes.machine = { 19 imports = [ 20 ../modules/profiles/headless.nix 21 ../modules/virtualisation/amazon-init.nix 22 ]; 23 services.openssh.enable = true; 24 system.switch.enable = true; 25 networking.hostName = ""; 26 environment.etc."ec2-metadata/user-data" = { 27 text = '' 28 #!/usr/bin/bash 29 30 echo successful > /tmp/evidence 31 32 # Emulate running nixos-rebuild switch, just without any building. 33 # https://github.com/nixos/nixpkgs/blob/4c62505847d88f16df11eff3c81bf9a453a4979e/nixos/modules/virtualisation/amazon-init.nix#L55 34 /run/current-system/bin/switch-to-configuration test 35 ''; 36 }; 37 }; 38 testScript = '' 39 # To wait until amazon-init terminates its run 40 unnamed.wait_for_unit("amazon-init.service") 41 42 unnamed.succeed("grep -q successful /tmp/evidence") 43 ''; 44}