Created
February 22, 2016 00:58
-
-
Save jodigiordano/11decb22171795379d09 to your computer and use it in GitHub Desktop.
Vagrantfile pour e-petitions
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.configure('2') do |config| | |
config.vm.provider 'virtualbox' do |v| | |
v.memory = 4096 | |
v.cpus = 4 | |
end | |
config.vm.box = 'debian/jessie64' | |
config.vm.provision :shell, inline: <<-SCRIPT | |
apt-get update -y | |
apt-get install -y postgresql | |
su postgres << EOF | |
whoami | |
if ! psql epets_development -c '' 2>&1; then | |
psql -c "CREATE ROLE epets WITH CREATEDB LOGIN PASSWORD 'epets';" | |
createdb epets_development | |
createdb epets_test | |
psql -c " | |
GRANT all privileges ON database epets_development TO epets; | |
ALTER DATABASE epets_development OWNER TO epets; | |
GRANT all privileges ON database epets_test TO epets; | |
ALTER DATABASE epets_test OWNER TO epets; | |
" | |
fi | |
EOF | |
if ! grep -q "listen_addresses = '\*'" /etc/postgresql/9.3/main/postgresql.conf; then | |
echo listen_addresses = \'*\' >> /etc/postgresql/9.3/main/postgresql.conf | |
fi | |
if ! grep -q "^host all all 0\.0\.0\.0/0 md5$" /etc/postgresql/9.3/main/pg_hba.conf; then | |
echo host all all 0.0.0.0/0 md5 >> /etc/postgresql/9.3/main/pg_hba.conf | |
fi | |
if [ ! -f /home/vagrant/.pgpass ]; then | |
touch /home/vagrant/.pgpass | |
echo "localhost:5432:epets_development:epets:epets" >> /home/vagrant/.pgpass | |
echo "localhost:5432:epets_test:epets:epets" >> /home/vagrant/.pgpass | |
chmod 600 /home/vagrant/.pgpass | |
fi | |
service postgresql restart | |
SCRIPT | |
config.vm.network :forwarded_port, guest: 5432, host: 15432 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Contenu de
.env.development
: