Fetch all EC2 metadata / user data in the initrd

Since we're already fetching one datum, we may as well fetch the
others needed by fetch-ec2-data. This also eliminates the dependency
on wget.
This commit is contained in:
Eelco Dolstra
2016-02-04 15:45:54 +01:00
parent 5c72b20dde
commit 2701665904
3 changed files with 34 additions and 29 deletions
+4 -5
View File
@@ -8,13 +8,12 @@ let
echo "attempting to fetch configuration from EC2 user data..."
export PATH=${config.nix.package}/bin:${pkgs.wget}/bin:${pkgs.systemd}/bin:${pkgs.gnugrep}/bin:${pkgs.gnused}/bin:${config.system.build.nixos-rebuild}/bin:$PATH
export PATH=${config.nix.package}/bin:${pkgs.systemd}/bin:${pkgs.gnugrep}/bin:${pkgs.gnused}/bin:${config.system.build.nixos-rebuild}/bin:$PATH
export NIX_PATH=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels
userData="$(mktemp)"
wget -q --wait=1 --tries=0 --retry-connrefused -O - http://169.254.169.254/2011-01-01/user-data > "$userData"
userData=/etc/ec2-metadata/user-data
if [[ $? -eq 0 ]]; then
if [ -s "$userData" ]; then
# If the user-data looks like it could be a nix expression,
# copy it over. Also, look for a magic three-hash comment and set
@@ -37,7 +36,7 @@ let
exit
fi
else
echo "failed to fetch user data"
echo "no user data is available"
exit
fi