Last active
August 29, 2015 14:17
-
-
Save rajiteh/199b9bcfe346296a2066 to your computer and use it in GitHub Desktop.
Vagrantfile for quick deployments using bootstrap.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
#vagrant plugin install vagrant-hostmanager | |
BOX_NAME="devbox" | |
ALIAS="#{BOX_NAME}.local" | |
HOSTNAME="#{BOX_NAME}-dev" | |
MOUNT_POINT="/vagrant" | |
Vagrant.configure(2) do |config| | |
config.vm.box = "ubuntu/trusty64" | |
config.vm.box_check_update = true | |
config.vm.network "private_network", type: "dhcp" | |
config.vm.hostname = HOSTNAME | |
config.vm.synced_folder '.', MOUNT_POINT | |
config.vm.provision "shell" do |s| | |
s.path = "https://gist.githubusercontent.com/rajiteh/f4f4e454e6f10c8ce42e/raw/bootstrap.sh" | |
s.args = [ "rbenv=2.0.0-p247", "nvm=0.10", "php", "apache", "mysql" ] | |
s.keep_color = true | |
s.privileged = false | |
end | |
config.hostmanager.enabled = true | |
config.hostmanager.manage_host = true | |
config.hostmanager.ignore_private_ip = false | |
config.hostmanager.include_offline = true | |
config.hostmanager.aliases = [ALIAS] | |
config.hostmanager.ip_resolver = proc do |vm, _| | |
if (vm.ssh_info && vm.ssh_info[:host]) | |
command = [ | |
"ssh", | |
"#{vm.ssh_info[:username]}@#{vm.ssh_info[:host]}", | |
"-p", vm.ssh_info[:port], | |
"-o", "Compression=yes", | |
"-o", "DSAAuthentication=yes", | |
"-o", "LogLevel=FATAL", | |
"-o", "StrictHostKeyChecking=no", | |
"-o", "UserKnownHostsFile=/dev/null", | |
"-o", "IdentitiesOnly=yes", | |
"-i", vm.ssh_info[:private_key_path], | |
"\"ifconfig eth1 | grep inet | cut -d: -f2 | cut -d' ' -f1\"" | |
].join(' ') | |
`#{command}`.strip | |
end | |
end | |
# Apache Virtual Host configuration. | |
# config.vm.provision "shell" do |s| | |
# $script = <<SCRIPT | |
# echo "Adding Virtual host entry\n" | |
# cat > /etc/apache2/sites-available/dev.conf << EOL | |
# <VirtualHost *:80> | |
# ServerName #{ALIAS} | |
# DocumentRoot #{MOUNT_POINT} | |
# </VirtualHost> | |
# EOL | |
# a2ensite dev | |
# service apache2 reload | |
# SCRIPT | |
# s.inline = $script | |
# end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment