-
-
Save gangsta/7d4f85015504e140dbbfd9552b8feec5 to your computer and use it in GitHub Desktop.
Vagrant file for Golang and PostgreSQL
This file contains 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 : | |
# All Vagrant configuration is done below. The "2" in Vagrant.configure | |
# configures the configuration version (we support older styles for | |
# backwards compatibility). Please don't change it unless you know what | |
# you're doing. | |
Vagrant.configure("2") do |config| | |
# The most common configuration options are documented and commented below. | |
# For a complete reference, please see the online documentation at | |
# https://docs.vagrantup.com. | |
# Every Vagrant development environment requires a box. You can search for | |
# boxes at https://atlas.hashicorp.com/search. | |
config.vm.box = "centos/7" | |
# PostgreSQL | |
config.vm.network "forwarded_port", guest: 5432, host: 25432 | |
# Install git | |
config.vm.provision "shell", inline: <<-SHELL | |
yum -y install git | |
SHELL | |
# Install golang and setup its environment | |
config.vm.provision "shell", privileged: false, inline: <<-SHELL | |
curl -O https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz | |
mkdir -p go/src go/bin go/pkg | |
echo " | |
export GOPATH=$HOME/go | |
export GOROOT=/usr/local/go | |
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin | |
" >> .bashrc | |
SHELL | |
config.vm.provision "shell", inline: <<-SHELL | |
tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz | |
SHELL | |
# Copy SSH key used to download git repositories | |
config.vm.provision "file", | |
source: "/home/mapaiva/.ssh/id_rsa", | |
destination: "~/.ssh/id_rsa" | |
config.vm.provision "file", | |
source: "/home/mapaiva/.ssh/id_rsa.pub", | |
destination: "~/.ssh/id_rsa.pub" | |
# Install PostreSQL | |
config.vm.provision "shell", inline: <<-SHELL | |
yum install -y postgresql-server postgresql | |
postgresql-setup initdb | |
systemctl enable postgresql | |
systemctl start postgresql | |
cd /tmp | |
sudo -u postgres psql -c "CREATE ROLE kerberos WITH LOGIN PASSWORD 'kerberos'" | |
sudo -u postgres createdb -O kerberos -E UTF8 kerberos | |
SHELL | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment