* Add multipath-tools (specifically, kpartx) to nova-compute's $PATH
so that it can inject SSH keys into disk images. * Use the injected key if available. svn path=/nixos/trunk/; revision=26724
This commit is contained in:
parent
2e2282bd5e
commit
4c2a0dc531
@ -18,18 +18,22 @@
|
||||
echo "setting host name..."
|
||||
${pkgs.nettools}/bin/hostname $(${pkgs.curl}/bin/curl http://169.254.169.254/1.0/meta-data/hostname)
|
||||
|
||||
echo "obtaining SSH key..."
|
||||
mkdir -p /root/.ssh
|
||||
${pkgs.curl}/bin/curl --retry 3 --retry-delay 0 --fail \
|
||||
-o /root/key.pub \
|
||||
http://169.254.169.254/1.0/meta-data/public-keys/0/openssh-key
|
||||
if [ $? -eq 0 -a -e /root/key.pub ]; then
|
||||
if ! grep -q -f /root/key.pub /root/.ssh/authorized_keys; then
|
||||
cat /root/key.pub >> /root/.ssh/authorized_keys
|
||||
echo "new key added to authorized_keys"
|
||||
# Don't download the SSH key if it has already been injected
|
||||
# into the image (a Nova feature).
|
||||
if ! [ -e /root/.ssh/authorized_keys ]; then
|
||||
echo "obtaining SSH key..."
|
||||
mkdir -p /root/.ssh
|
||||
${pkgs.curl}/bin/curl --retry 3 --retry-delay 0 --fail \
|
||||
-o /root/key.pub \
|
||||
http://169.254.169.254/1.0/meta-data/public-keys/0/openssh-key
|
||||
if [ $? -eq 0 -a -e /root/key.pub ]; then
|
||||
if ! grep -q -f /root/key.pub /root/.ssh/authorized_keys; then
|
||||
cat /root/key.pub >> /root/.ssh/authorized_keys
|
||||
echo "new key added to authorized_keys"
|
||||
fi
|
||||
chmod 600 /root/.ssh/authorized_keys
|
||||
rm -f /root/key.pub
|
||||
fi
|
||||
chmod 600 /root/.ssh/authorized_keys
|
||||
rm -f /root/key.pub
|
||||
fi
|
||||
|
||||
# Print the host public key on the console so that the user
|
||||
|
@ -104,7 +104,7 @@ in
|
||||
|
||||
path =
|
||||
[ pkgs.sudo pkgs.vlan pkgs.nettools pkgs.iptables pkgs.qemu_kvm
|
||||
pkgs.e2fsprogs pkgs.utillinux
|
||||
pkgs.e2fsprogs pkgs.utillinux pkgs.multipath_tools
|
||||
];
|
||||
|
||||
exec = "${nova}/bin/nova-compute --nodaemon --verbose";
|
||||
|
Loading…
Reference in New Issue
Block a user