Skip to content

Commit

Permalink
Dynamically generate SSH key pair
Browse files Browse the repository at this point in the history
  • Loading branch information
rlowe committed Aug 26, 2015
1 parent 9ade786 commit f4eea30
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 57 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ vagrant/db1-post-install.sh
vagrant/db2-post-install.sh
vagrant/db3-post-install.sh
vagrant/db4-post-install.sh
vagrant/vagrant-ssh-key
vagrant/vagrant-ssh-key.pub
6 changes: 6 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ BOX = ENV['VAGRANT_BOX'].nil? || ENV['VAGRANT_BOX'].empty? ? 'nrel/CentOS-6.6-x8

VAGRANTFILE_API_VERSION = "2"

system("
if [ #{ARGV[0]} = 'up' ]; then
ssh-keygen -t rsa -b 768 -N '' -q -f vagrant/vagrant-ssh-key
fi
")

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = BOX
config.vm.box_download_insecure = true
Expand Down
8 changes: 8 additions & 0 deletions vagrant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,11 @@ Ubuntu
%> export VAGRANT_SERVER_URL="https://atlas.hashicorp.com"
%> export VAGRANT_BOX='chef/ubuntu-12.04'
%> vagrant up

TO DO
=====

- Support other MySQL's (5.5, 5.7, MariaDB)
- Support customizable replication configurations
- Better my.cnf templates

59 changes: 2 additions & 57 deletions vagrant/base-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,63 +51,8 @@ EOF
# Generated a random SSH keypair to be used by the vagrant user for convenience
mkdir -p /home/vagrant/.ssh

cat <<-EOF > /home/vagrant/.ssh/id_rsa
-----BEGIN RSA PRIVATE KEY-----
MIIJKAIBAAKCAgEA6iIWUlkGatU8P3Gk2VLWUa6Ub/cxITVUiUXi55QrHkWGjAgn
X/mS0MpT4BH/JIYAo/WdE3fMcLrNKWMjBOxph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khgCj9Z0Td8xwus0pYyME7GmHf4/Bpl7i6RFXto84ZyEwgkwC+OMqZh4g8JsZJkd/Fhf0JS7UaZqiL/9PbyCnZ0b2dEji6sXcLN8cZA9qUn1j1MccRozDsUDwQRWypbszgarrTJSwRzjmh2q+L9iAA91qqt0fDJS3OCZnFtF07ZfSv2vAyrZuhnDUg4YRzt8ol4uX0oVGE+Ihb/uchVa/EJFhrDa95wH4NUUIwc6j4D7p4gBiZbjBZsokYUoqhJpnSTIQBZa8FTo3VgR2KFaCz3iDj3DsIW8IPdwTtcHoGQSgZYah1fzZWb25VOlONqfX+ugCbeJYx/oOV2J4wqtQK0QK5Gl8nF293hs96ZCethxvf2AfbZCGPJmp2n5jTTXP4zw1xPKaeQCjmYt49xWY/r78Few86x4W6edw/On+oLVCh9bfBgIwK6Pzy6fvz08IT5G2cI37JbKCLpgt5qUeuHAOxhpvf73Cdi0iUWZZpBwA/GZdMPUaZx9803yqpEO0L0h2N3yQhdk5Ax1/OFtgu7c+0K6g3N33CW05gv4nzwTuuMRtFT7PLeyaHKr+G7gmkRl1mqJDrCRTRXxNuUqJNXOBdLH1ijhACPmIhMcGRKUblQ== vagrant@orchestrator
EOF
cp /orchestrator/vagrant/vagrant-ssh-key /home/vagrant/.ssh/id_rsa
cp /orchestrator/vagrant/vagrant-ssh-key.pub /home/vagrant/.ssh/id_rsa.pub

cat <<EOF > /home/vagrant/.ssh/config
Host admin
Expand Down

0 comments on commit f4eea30

Please sign in to comment.