diff options
author | Matej Urbas <matej.urbas@gmail.com> | 2021-04-18 10:19:06 +0100 |
---|---|---|
committer | Matej Urbas <matej.urbas@gmail.com> | 2021-04-18 10:19:06 +0100 |
commit | db5b547b2542d01661ad602b437d88e3c75a8606 (patch) | |
tree | 0a51ab550503b5c1ade568e1ccdc7f6f01c04882 /nixos/tests | |
parent | c0e881852006b132236cbf0301bd1939bb50867e (diff) | |
download | nixpkgs-db5b547b2542d01661ad602b437d88e3c75a8606.tar nixpkgs-db5b547b2542d01661ad602b437d88e3c75a8606.tar.gz nixpkgs-db5b547b2542d01661ad602b437d88e3c75a8606.tar.bz2 nixpkgs-db5b547b2542d01661ad602b437d88e3c75a8606.tar.lz nixpkgs-db5b547b2542d01661ad602b437d88e3c75a8606.tar.xz nixpkgs-db5b547b2542d01661ad602b437d88e3c75a8606.tar.zst nixpkgs-db5b547b2542d01661ad602b437d88e3c75a8606.zip |
nixos/amazon-init: add user-data shell script support
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/all-tests.nix | 1 | ||||
-rw-r--r-- | nixos/tests/amazon-init-shell.nix | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index fb45ec1a310..d4fdc668e76 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -24,6 +24,7 @@ in _3proxy = handleTest ./3proxy.nix {}; acme = handleTest ./acme.nix {}; agda = handleTest ./agda.nix {}; + amazon-init-shell = handleTest ./amazon-init-shell.nix {}; ammonite = handleTest ./ammonite.nix {}; atd = handleTest ./atd.nix {}; avahi = handleTest ./avahi.nix {}; diff --git a/nixos/tests/amazon-init-shell.nix b/nixos/tests/amazon-init-shell.nix new file mode 100644 index 00000000000..f9268b2f3a0 --- /dev/null +++ b/nixos/tests/amazon-init-shell.nix @@ -0,0 +1,40 @@ +# This test verifies that the amazon-init service can treat the `user-data` ec2 +# metadata file as a shell script. If amazon-init detects that `user-data` is a +# script (based on the presence of the shebang #! line) it executes it and +# exits. +# Note that other tests verify that amazon-init can treat user-data as a nixos +# configuration expression. + +{ system ? builtins.currentSystem, + config ? {}, + pkgs ? import ../.. { inherit system config; } +}: + +with import ../lib/testing-python.nix { inherit system pkgs; }; +with pkgs.lib; + +makeTest { + name = "amazon-init"; + meta = with maintainers; { + maintainers = [ urbas ]; + }; + machine = { ... }: + { + imports = [ ../modules/profiles/headless.nix ../modules/virtualisation/amazon-init.nix ]; + services.openssh.enable = true; + networking.hostName = ""; + environment.etc."ec2-metadata/user-data" = { + text = '' + #!/usr/bin/bash + + echo successful > /tmp/evidence + ''; + }; + }; + testScript = '' + # To wait until amazon-init terminates its run + unnamed.wait_for_unit("amazon-init.service") + + unnamed.succeed("grep -q successful /tmp/evidence") + ''; +} |