diff --git a/nixos/modules/virtualisation/nova-config.nix b/nixos/modules/virtualisation/nova-config.nix index fef20d498e9..c944fff96a8 100644 --- a/nixos/modules/virtualisation/nova-config.nix +++ b/nixos/modules/virtualisation/nova-config.nix @@ -8,6 +8,7 @@ with lib; ../profiles/headless.nix # The Openstack Metadata service exposes data on an EC2 API also. ./ec2-data.nix + ./amazon-init.nix ]; config = { @@ -32,7 +33,7 @@ with lib; path = [ pkgs.wget ]; description = "Fetch Metadata on startup"; wantedBy = [ "multi-user.target" ]; - before = [ "apply-ec2-data.service" ]; + before = [ "apply-ec2-data.service" "amazon-init.service"]; wants = [ "network-online.target" ]; after = [ "network-online.target" ]; script = diff --git a/nixos/tests/nova-image.nix b/nixos/tests/nova-image.nix index 488649b70e6..7934ab31c70 100644 --- a/nixos/tests/nova-image.nix +++ b/nixos/tests/nova-image.nix @@ -19,12 +19,11 @@ let ]; }).config.system.build.novaImage; -in - makeEc2Test { - name = "nova-ec2-metadata"; +in { + metadata = makeEc2Test { + name = "nova-ec2-metadata"; inherit image; - sshPublicKey = snakeOilPublicKey; # That's right folks! My user's key is also the host key! - + sshPublicKey = snakeOilPublicKey; userData = '' SSH_HOST_ED25519_KEY_PUB:${snakeOilPublicKey} SSH_HOST_ED25519_KEY:${replaceStrings ["\n"] ["|"] snakeOilPrivateKey} @@ -57,4 +56,29 @@ in $machine->start; $machine->waitForFile("/etc/ec2-metadata/user-data"); ''; - } + }; + + userdata = makeEc2Test { + name = "nova-ec2-metadata"; + inherit image; + sshPublicKey = snakeOilPublicKey; + userData = '' + { pkgs, ... }: + { + imports = [ + + + + ]; + environment.etc.testFile = { + text = "whoa"; + }; + } + ''; + script = '' + $machine->start; + $machine->waitForFile("/etc/testFile"); + $machine->succeed("cat /etc/testFile | grep -q 'whoa'"); + ''; + }; +}