closing #191 by adding the VM's private SSH key into the VM.
authorBryan <btbonval@gmail.com>
Wed, 11 Dec 2013 06:30:03 +0000 (01:30 -0500)
committerBryan <btbonval@gmail.com>
Wed, 11 Dec 2013 06:30:03 +0000 (01:30 -0500)
Vagrantfile
fabfile.py

index b7f2b05a9de3f29cf8de908de49f7419f0355a75..9cbf0bef6a841c205e146bd405b23ac20f86d109 100644 (file)
 # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
 VAGRANTFILE_API_VERSION = "2"
 
-# Install fabric so that the KarmaWorld fabfile may be run.
+# Copy the vagrant SSH key into the VM so vagrant can SSH to localhost within
+# the VM. Continued in the shell script below.
+# http://serverfault.com/questions/491343/how-can-i-move-my-deploy-key-into-vagrant#comment549259_491345
+git_ssh_key = File.read('~/.vagrant.d/insecure_private_key');
 
 # build a shell script that installs prereqs, configures the database, sets up
 # the user/group associations, pulls in the code from the host machine, sets up
 # some external dependency configs, and then runs fabric.
 shellscript = <<SCRIPT
+cat >>/home/vagrant/.ssh/insecure_private_key <<EOF
+#{git_ssh_key}
+EOF
+chown vagrant:vagrant /home/vagrant/.ssh/insecure_private_key
+chmod 600 /home/vagrant/.ssh/insecure_private_key
+cat >>/home/vagrant/.ssh/config <<EOF
+Host localhost
+    User vagrant
+    IdentityFile ~/.ssh/insecure_private_key
+
+Host 127.0.0.1
+    User vagrant
+    IdentityFile ~/.ssh/insecure_private_key
+EOF
+chmod 644 /home/vagrant/.ssh/config
+
 apt-get update
 apt-get upgrade -y
 apt-get install -y python-pip postgresql python-virtualenv virtualenvwrapper \
index b54cd52e03d9c4a99b790a3acbfaf7b112af2493..1afb8e5a9a1af13f8ef11cb2547b64922c6a7643 100644 (file)
@@ -19,6 +19,8 @@ env.code_root = env.proj_root
 env.env_root = env.proj_root
 env.supervisor_conf = '{0}/confs/{1}/supervisord.conf'.format(env.code_root, env.branch)
 
+env.use_ssh_config = True
+
 ######## Define host(s)
 def here():
     """