From 463e8b3b008028002f8ae96bb29fa758afefc05b Mon Sep 17 00:00:00 2001 From: Sean Collins Date: Tue, 18 Nov 2014 17:39:35 -0500 Subject: [PATCH 01/12] add Vagrantfile (ubuntu/trusty64 with port 3000 forwarded) --- Vagrantfile | 122 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 Vagrantfile diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 00000000..91029bfe --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,122 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! +VAGRANTFILE_API_VERSION = "2" + +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| + # All Vagrant configuration is done here. The most common configuration + # options are documented and commented below. For a complete reference, + # please see the online documentation at vagrantup.com. + + # Every Vagrant virtual environment requires a box to build off of. + config.vm.box = "ubuntu/trusty64" + + # Disable automatic box update checking. If you disable this, then + # boxes will only be checked for updates when the user runs + # `vagrant box outdated`. This is not recommended. + # config.vm.box_check_update = false + + # Create a forwarded port mapping which allows access to a specific port + # within the machine from a port on the host machine. In the example below, + # accessing "localhost:8080" will access port 80 on the guest machine. + config.vm.network "forwarded_port", guest: 3000, host: 3000 + + # Create a private network, which allows host-only access to the machine + # using a specific IP. + # config.vm.network "private_network", ip: "192.168.33.10" + + # Create a public network, which generally matched to bridged network. + # Bridged networks make the machine appear as another physical device on + # your network. + # config.vm.network "public_network" + + # If true, then any SSH connections made will enable agent forwarding. + # Default value: false + # config.ssh.forward_agent = true + + # Share an additional folder to the guest VM. The first argument is + # the path on the host to the actual folder. The second argument is + # the path on the guest to mount the folder. And the optional third + # argument is a set of non-required options. + # config.vm.synced_folder "../data", "/vagrant_data" + + # Provider-specific configuration so you can fine-tune various + # backing providers for Vagrant. These expose provider-specific options. + # Example for VirtualBox: + # + #config.vm.provider "virtualbox" do |vb| + # # Don't boot with headless mode + # vb.gui = true + # + # # Use VBoxManage to customize the VM. For example to change memory: + # vb.customize ["modifyvm", :id, "--memory", "1024"] + #end + # + # View the documentation for the provider you're using for more + # information on available options. + + # Enable provisioning with CFEngine. CFEngine Community packages are + # automatically installed. For example, configure the host as a + # policy server and optionally a policy file to run: + # + # config.vm.provision "cfengine" do |cf| + # cf.am_policy_hub = true + # # cf.run_file = "motd.cf" + # end + # + # You can also configure and bootstrap a client to an existing + # policy server: + # + # config.vm.provision "cfengine" do |cf| + # cf.policy_server_address = "10.0.2.15" + # end + + # Enable provisioning with Puppet stand alone. Puppet manifests + # are contained in a directory path relative to this Vagrantfile. + # You will need to create the manifests directory and a manifest in + # the file default.pp in the manifests_path directory. + # + # config.vm.provision "puppet" do |puppet| + # puppet.manifests_path = "manifests" + # puppet.manifest_file = "default.pp" + # end + + # Enable provisioning with chef solo, specifying a cookbooks path, roles + # path, and data_bags path (all relative to this Vagrantfile), and adding + # some recipes and/or roles. + # + # config.vm.provision "chef_solo" do |chef| + # chef.cookbooks_path = "../my-recipes/cookbooks" + # chef.roles_path = "../my-recipes/roles" + # chef.data_bags_path = "../my-recipes/data_bags" + # chef.add_recipe "mysql" + # chef.add_role "web" + # + # # You may also specify custom JSON attributes: + # chef.json = { mysql_password: "foo" } + # end + + # Enable provisioning with chef server, specifying the chef server URL, + # and the path to the validation key (relative to this Vagrantfile). + # + # The Opscode Platform uses HTTPS. Substitute your organization for + # ORGNAME in the URL and validation key. + # + # If you have your own Chef Server, use the appropriate URL, which may be + # HTTP instead of HTTPS depending on your configuration. Also change the + # validation key to validation.pem. + # + # config.vm.provision "chef_client" do |chef| + # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" + # chef.validation_key_path = "ORGNAME-validator.pem" + # end + # + # If you're using the Opscode platform, your validator client is + # ORGNAME-validator, replacing ORGNAME with your organization name. + # + # If you have your own Chef Server, the default validation client name is + # chef-validator, unless you changed the configuration. + # + # chef.validation_client_name = "ORGNAME-validator" +end From 1245ad8e74224a8479a1f1c7c232531a72965e28 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Tue, 18 Nov 2014 15:29:22 -0800 Subject: [PATCH 02/12] remove some fluff and add synced repo --- .../default/virtualbox/action_provision | 1 + .../default/virtualbox/action_set_name | 1 + .vagrant/machines/default/virtualbox/id | 1 + .../machines/default/virtualbox/index_uuid | 1 + .../default/virtualbox/synced_folders | 1 + Vagrantfile | 52 +------------------ 6 files changed, 7 insertions(+), 50 deletions(-) create mode 100644 .vagrant/machines/default/virtualbox/action_provision create mode 100644 .vagrant/machines/default/virtualbox/action_set_name create mode 100644 .vagrant/machines/default/virtualbox/id create mode 100644 .vagrant/machines/default/virtualbox/index_uuid create mode 100644 .vagrant/machines/default/virtualbox/synced_folders diff --git a/.vagrant/machines/default/virtualbox/action_provision b/.vagrant/machines/default/virtualbox/action_provision new file mode 100644 index 00000000..082cd93a --- /dev/null +++ b/.vagrant/machines/default/virtualbox/action_provision @@ -0,0 +1 @@ +1.5:2c3a0968-e1c0-4512-8628-229346508c41 \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/action_set_name b/.vagrant/machines/default/virtualbox/action_set_name new file mode 100644 index 00000000..50175e15 --- /dev/null +++ b/.vagrant/machines/default/virtualbox/action_set_name @@ -0,0 +1 @@ +1416353280 \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/id b/.vagrant/machines/default/virtualbox/id new file mode 100644 index 00000000..e25a2a34 --- /dev/null +++ b/.vagrant/machines/default/virtualbox/id @@ -0,0 +1 @@ +2c3a0968-e1c0-4512-8628-229346508c41 \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/index_uuid b/.vagrant/machines/default/virtualbox/index_uuid new file mode 100644 index 00000000..bba2c18e --- /dev/null +++ b/.vagrant/machines/default/virtualbox/index_uuid @@ -0,0 +1 @@ +b9e777093a5a40868b2e5370380e495d \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/synced_folders b/.vagrant/machines/default/virtualbox/synced_folders new file mode 100644 index 00000000..c50517ff --- /dev/null +++ b/.vagrant/machines/default/virtualbox/synced_folders @@ -0,0 +1 @@ +{"virtualbox":{"/home/vagrant/refugerestrooms":{"guestpath":"/home/vagrant/refugerestrooms","hostpath":"/Users/michaelwood/projects/refugerestrooms","disabled":false},"/vagrant":{"guestpath":"/vagrant","hostpath":"/Users/michaelwood/projects/refugerestrooms","disabled":false}}} \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile index 91029bfe..449544ad 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -11,6 +11,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Every Vagrant virtual environment requires a box to build off of. config.vm.box = "ubuntu/trusty64" + config.vm.hostname = "refugerestrooms" # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs @@ -39,7 +40,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # the path on the host to the actual folder. The second argument is # the path on the guest to mount the folder. And the optional third # argument is a set of non-required options. - # config.vm.synced_folder "../data", "/vagrant_data" + config.vm.synced_folder ".", "/home/vagrant/refugerestrooms" # Provider-specific configuration so you can fine-tune various # backing providers for Vagrant. These expose provider-specific options. @@ -56,32 +57,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # View the documentation for the provider you're using for more # information on available options. - # Enable provisioning with CFEngine. CFEngine Community packages are - # automatically installed. For example, configure the host as a - # policy server and optionally a policy file to run: - # - # config.vm.provision "cfengine" do |cf| - # cf.am_policy_hub = true - # # cf.run_file = "motd.cf" - # end - # - # You can also configure and bootstrap a client to an existing - # policy server: - # - # config.vm.provision "cfengine" do |cf| - # cf.policy_server_address = "10.0.2.15" - # end - - # Enable provisioning with Puppet stand alone. Puppet manifests - # are contained in a directory path relative to this Vagrantfile. - # You will need to create the manifests directory and a manifest in - # the file default.pp in the manifests_path directory. - # - # config.vm.provision "puppet" do |puppet| - # puppet.manifests_path = "manifests" - # puppet.manifest_file = "default.pp" - # end - # Enable provisioning with chef solo, specifying a cookbooks path, roles # path, and data_bags path (all relative to this Vagrantfile), and adding # some recipes and/or roles. @@ -96,27 +71,4 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # # You may also specify custom JSON attributes: # chef.json = { mysql_password: "foo" } # end - - # Enable provisioning with chef server, specifying the chef server URL, - # and the path to the validation key (relative to this Vagrantfile). - # - # The Opscode Platform uses HTTPS. Substitute your organization for - # ORGNAME in the URL and validation key. - # - # If you have your own Chef Server, use the appropriate URL, which may be - # HTTP instead of HTTPS depending on your configuration. Also change the - # validation key to validation.pem. - # - # config.vm.provision "chef_client" do |chef| - # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME" - # chef.validation_key_path = "ORGNAME-validator.pem" - # end - # - # If you're using the Opscode platform, your validator client is - # ORGNAME-validator, replacing ORGNAME with your organization name. - # - # If you have your own Chef Server, the default validation client name is - # chef-validator, unless you changed the configuration. - # - # chef.validation_client_name = "ORGNAME-validator" end From ace306d280de8af205a96eb466cfc6dc25b06b0d Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Tue, 18 Nov 2014 15:31:54 -0800 Subject: [PATCH 03/12] add vagrant working directory to ignore --- .gitignore | 3 +++ .vagrant/machines/default/virtualbox/action_provision | 1 - .vagrant/machines/default/virtualbox/action_set_name | 1 - .vagrant/machines/default/virtualbox/id | 1 - .vagrant/machines/default/virtualbox/index_uuid | 1 - .vagrant/machines/default/virtualbox/synced_folders | 1 - 6 files changed, 3 insertions(+), 5 deletions(-) delete mode 100644 .vagrant/machines/default/virtualbox/action_provision delete mode 100644 .vagrant/machines/default/virtualbox/action_set_name delete mode 100644 .vagrant/machines/default/virtualbox/id delete mode 100644 .vagrant/machines/default/virtualbox/index_uuid delete mode 100644 .vagrant/machines/default/virtualbox/synced_folders diff --git a/.gitignore b/.gitignore index 6998627a..5f1cd0d5 100644 --- a/.gitignore +++ b/.gitignore @@ -42,3 +42,6 @@ geocoder.rb ## editor temp files *.swp *.swo + +## Vagrant working directory +.vagrant diff --git a/.vagrant/machines/default/virtualbox/action_provision b/.vagrant/machines/default/virtualbox/action_provision deleted file mode 100644 index 082cd93a..00000000 --- a/.vagrant/machines/default/virtualbox/action_provision +++ /dev/null @@ -1 +0,0 @@ -1.5:2c3a0968-e1c0-4512-8628-229346508c41 \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/action_set_name b/.vagrant/machines/default/virtualbox/action_set_name deleted file mode 100644 index 50175e15..00000000 --- a/.vagrant/machines/default/virtualbox/action_set_name +++ /dev/null @@ -1 +0,0 @@ -1416353280 \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/id b/.vagrant/machines/default/virtualbox/id deleted file mode 100644 index e25a2a34..00000000 --- a/.vagrant/machines/default/virtualbox/id +++ /dev/null @@ -1 +0,0 @@ -2c3a0968-e1c0-4512-8628-229346508c41 \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/index_uuid b/.vagrant/machines/default/virtualbox/index_uuid deleted file mode 100644 index bba2c18e..00000000 --- a/.vagrant/machines/default/virtualbox/index_uuid +++ /dev/null @@ -1 +0,0 @@ -b9e777093a5a40868b2e5370380e495d \ No newline at end of file diff --git a/.vagrant/machines/default/virtualbox/synced_folders b/.vagrant/machines/default/virtualbox/synced_folders deleted file mode 100644 index c50517ff..00000000 --- a/.vagrant/machines/default/virtualbox/synced_folders +++ /dev/null @@ -1 +0,0 @@ -{"virtualbox":{"/home/vagrant/refugerestrooms":{"guestpath":"/home/vagrant/refugerestrooms","hostpath":"/Users/michaelwood/projects/refugerestrooms","disabled":false},"/vagrant":{"guestpath":"/vagrant","hostpath":"/Users/michaelwood/projects/refugerestrooms","disabled":false}}} \ No newline at end of file From 5255a991b7bb66b275a4d645a448a6f9139e1ba3 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Tue, 18 Nov 2014 15:50:52 -0800 Subject: [PATCH 04/12] add a box name --- Vagrantfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 449544ad..c7f90542 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -3,6 +3,7 @@ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" +boxname = "refugerestrooms" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # All Vagrant configuration is done here. The most common configuration @@ -11,16 +12,14 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Every Vagrant virtual environment requires a box to build off of. config.vm.box = "ubuntu/trusty64" - config.vm.hostname = "refugerestrooms" + config.vm.hostname = boxname # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs # `vagrant box outdated`. This is not recommended. # config.vm.box_check_update = false - # Create a forwarded port mapping which allows access to a specific port - # within the machine from a port on the host machine. In the example below, - # accessing "localhost:8080" will access port 80 on the guest machine. + # Access the rails server at localhost:3000 config.vm.network "forwarded_port", guest: 3000, host: 3000 # Create a private network, which allows host-only access to the machine @@ -46,13 +45,14 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # backing providers for Vagrant. These expose provider-specific options. # Example for VirtualBox: # - #config.vm.provider "virtualbox" do |vb| + config.vm.provider "virtualbox" do |vb| + vb.name = boxname # # Don't boot with headless mode # vb.gui = true # # # Use VBoxManage to customize the VM. For example to change memory: # vb.customize ["modifyvm", :id, "--memory", "1024"] - #end + end # # View the documentation for the provider you're using for more # information on available options. From 9464c57a3fc17f5d74d329e06d418487a1c0dd87 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Tue, 18 Nov 2014 23:23:59 -0800 Subject: [PATCH 05/12] add vagrant setup script --- Vagrantfile | 44 +++++++---------------- config/database.yml | 2 +- refugerestrooms | 1 + script/setup_vagrant.sh | 80 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 32 deletions(-) create mode 120000 refugerestrooms create mode 100644 script/setup_vagrant.sh diff --git a/Vagrantfile b/Vagrantfile index c7f90542..d207c031 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -3,16 +3,12 @@ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! VAGRANTFILE_API_VERSION = "2" -boxname = "refugerestrooms" +BOXNAME = "refugerestrooms" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - # All Vagrant configuration is done here. The most common configuration - # options are documented and commented below. For a complete reference, - # please see the online documentation at vagrantup.com. - - # Every Vagrant virtual environment requires a box to build off of. + # Ubuntu 14.04 base box config.vm.box = "ubuntu/trusty64" - config.vm.hostname = boxname + config.vm.hostname = BOXNAME # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs @@ -22,40 +18,26 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Access the rails server at localhost:3000 config.vm.network "forwarded_port", guest: 3000, host: 3000 - # Create a private network, which allows host-only access to the machine - # using a specific IP. + # Use this if you need to copy files via scp or something # config.vm.network "private_network", ip: "192.168.33.10" - # Create a public network, which generally matched to bridged network. - # Bridged networks make the machine appear as another physical device on - # your network. - # config.vm.network "public_network" - # If true, then any SSH connections made will enable agent forwarding. # Default value: false # config.ssh.forward_agent = true - # Share an additional folder to the guest VM. The first argument is - # the path on the host to the actual folder. The second argument is - # the path on the guest to mount the folder. And the optional third - # argument is a set of non-required options. + # Share refuge repo in vagrant home folder config.vm.synced_folder ".", "/home/vagrant/refugerestrooms" - # Provider-specific configuration so you can fine-tune various - # backing providers for Vagrant. These expose provider-specific options. - # Example for VirtualBox: - # + # View virtualbox provider docs for more options config.vm.provider "virtualbox" do |vb| - vb.name = boxname - # # Don't boot with headless mode - # vb.gui = true - # - # # Use VBoxManage to customize the VM. For example to change memory: - # vb.customize ["modifyvm", :id, "--memory", "1024"] + vb.name = BOXNAME + # Uncomment this if you need more than default of 512 + #vb.customize ["modifyvm", :id, "--memory", "1024"] end - # - # View the documentation for the provider you're using for more - # information on available options. + + # If this gets bigger I can make it into a chef run + # mi-wood + config.vm.provision "shell", path: "script/setup_vagrant.sh", privileged: false # Enable provisioning with chef solo, specifying a cookbooks path, roles # path, and data_bags path (all relative to this Vagrantfile), and adding diff --git a/config/database.yml b/config/database.yml index 1bdf148e..ff95246e 100644 --- a/config/database.yml +++ b/config/database.yml @@ -3,7 +3,7 @@ development: encoding: unicode database: bathrooms_development pool: 5 - host: localhost + host: "" test: adapter: postgresql diff --git a/refugerestrooms b/refugerestrooms new file mode 120000 index 00000000..d25c843a --- /dev/null +++ b/refugerestrooms @@ -0,0 +1 @@ +/home/vagrant/refugerestrooms \ No newline at end of file diff --git a/script/setup_vagrant.sh b/script/setup_vagrant.sh new file mode 100644 index 00000000..0ee13515 --- /dev/null +++ b/script/setup_vagrant.sh @@ -0,0 +1,80 @@ +#!/bin/bash +# This script is run from vagrant to setup packages +# It's only tested with ubuntu 14.04 +set -e + +REFUGE_PATH=$HOME/refugerestrooms + +# required packages +declare -A packages +packages=( + ["git"]="1:1.9.1-1" + ["nodejs"]="0.10.25~dfsg2-2ubuntu1" + ["phantomjs"]="1.9.0-1" + ["postgresql-server-dev-9.3"]="9.3.5-0ubuntu0.14.04.1" + ["postgresql-contrib-9.3"]="9.3.5-0ubuntu0.14.04.1" +) + +for package in "${!packages[@]}" +do + version=${packages["$package"]} + if dpkg -s $package | grep -q $version; then + echo $package' installed, skipping' + else + echo 'installing '$i', version '$version'...' + sudo apt-get install -y -q $package=$version + fi +done + +# Install rbenv and ruby-build +echo 'installing rbenv...' +cd +if ! [ -d .rbenv ]; then + git clone git://github.com/sstephenson/rbenv.git .rbenv +fi +if ! grep -q '.rbenv/bin' $HOME/.bashrc; then + echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc +fi +if ! grep -q 'rbenv init' $HOME/.bashrc; then + echo 'eval "$(rbenv init -)"' >> ~/.bashrc +fi +if ! [ -d ~/.rbenv/plugins/ruby-build ]; then + git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build +fi +if ! grep -q ruby-build $HOME/.bashrc; then + echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc +fi + +# source .bashrc doesn't appear to be setting the path +# adding the following for now: +export PATH="$HOME/.rbenv/bin:$PATH" +eval "$(rbenv init -)" +export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH" + +# Install ruby +ruby_version=`cat $REFUGE_PATH/.ruby-version` +if rbenv versions | grep $ruby_version; then + echo 'ruby '$ruby_version' installed, skipping...' +else + echo 'install ruby '$ruby_version + rbenv install $ruby_version +fi + +# Install bundle reqs +cd $REFUGE_PATH +if which bundle; then + echo 'bundler installed, skipping' +else + echo 'Installing bundler...' + gem install bundler --no-rdoc --no-ri -q +fi +echo 'Running bundle install...' +bundle install --quiet + +# Creating postres user +echo 'Creating vagrant postgres user...' +sudo -u postgres createuser vagrant + +# Seed db +echo 'Seeding db...' +rake db:setup From 1bec70cbdd2ad0875635723c8ee7d4ec03d95aac Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Tue, 18 Nov 2014 23:27:17 -0800 Subject: [PATCH 06/12] remove link --- refugerestrooms | 1 - 1 file changed, 1 deletion(-) delete mode 120000 refugerestrooms diff --git a/refugerestrooms b/refugerestrooms deleted file mode 120000 index d25c843a..00000000 --- a/refugerestrooms +++ /dev/null @@ -1 +0,0 @@ -/home/vagrant/refugerestrooms \ No newline at end of file From eacd4d63e18a6e0a6bd856fa3d7f86ac7ceb443d Mon Sep 17 00:00:00 2001 From: Sean Collins Date: Wed, 19 Nov 2014 11:02:22 -0500 Subject: [PATCH 07/12] add --createdb and --superuser flags to the vagrant postgres user --- script/setup_vagrant.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/setup_vagrant.sh b/script/setup_vagrant.sh index 0ee13515..569dc299 100644 --- a/script/setup_vagrant.sh +++ b/script/setup_vagrant.sh @@ -73,7 +73,7 @@ bundle install --quiet # Creating postres user echo 'Creating vagrant postgres user...' -sudo -u postgres createuser vagrant +sudo -u postgres createuser vagrant --createdb --superuser # Seed db echo 'Seeding db...' From 6ab7f8a02555a45b550134a4b6ebd461090ce164 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Wed, 19 Nov 2014 12:24:27 -0800 Subject: [PATCH 08/12] Add contributing.md and bundle install change --- .gitignore | 1 + CONTRIBUTING.md | 21 +++++++++++++++++++++ README.md | 5 ----- script/setup_vagrant.sh | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/.gitignore b/.gitignore index 5f1cd0d5..23643e5a 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ geocoder.rb ## Vagrant working directory .vagrant +ruby diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..3e5eb8a0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,21 @@ +#Contributing + +### 1 Fork and clone the repository. + +### 2 Install Vagrant. +https://www.vagrantup.com/downloads + +### 3 Capture the powers of vagrant + In the repo dir: + * vagrant up + If changes have been made since running vagrant up: + * vagrant provision + To login to the machine: + * vagrant ssh + +### 4 Optional tasks: +run rake db:fix_accents to clean up encoding problems in the safe2pee data. (Use rake db:fix_accents[dry_run] to preview the changes.) + +### 5 Assets +* [Assets Repo](https://github.com/RefugeRestrooms/refuge_assets) + diff --git a/README.md b/README.md index 7b289212..b1a6756b 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,6 @@ REFUGE is an effort to fill the hole left by the now-defunct Safe2Pee website. I This project is open source. Feel free to contribute. We could use the help. - -## Set Up For Contributing -* [Enviroment Setup Wiki](https://github.com/RefugeRestrooms/refugerestrooms/wiki/Setting-up-the-Dev-Enviroment-for-Contributing-to-Refuge-Restrooms) -* [Assets Repo](https://github.com/RefugeRestrooms/refuge_assets) - ## Deployment Currently right now we deploy to heroku. Our application is small enough that it is free to host on Heroku, and we dont mind the server having to wake up if nobody has accessed the site in a while. diff --git a/script/setup_vagrant.sh b/script/setup_vagrant.sh index 569dc299..7ccedabd 100644 --- a/script/setup_vagrant.sh +++ b/script/setup_vagrant.sh @@ -69,7 +69,7 @@ else gem install bundler --no-rdoc --no-ri -q fi echo 'Running bundle install...' -bundle install --quiet +bundle install # Creating postres user echo 'Creating vagrant postgres user...' From adb310a3065a7bf854a688060aec96ca42723be0 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Wed, 19 Nov 2014 12:27:05 -0800 Subject: [PATCH 09/12] fix contributing.md syntax --- CONTRIBUTING.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3e5eb8a0..db91cf06 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,12 +6,9 @@ https://www.vagrantup.com/downloads ### 3 Capture the powers of vagrant - In the repo dir: - * vagrant up - If changes have been made since running vagrant up: - * vagrant provision - To login to the machine: - * vagrant ssh + * In the repo dir: vagrant up + * If changes have been made since running vagrant up: vagrant provision + * To login to the machine: vagrant ssh ### 4 Optional tasks: run rake db:fix_accents to clean up encoding problems in the safe2pee data. (Use rake db:fix_accents[dry_run] to preview the changes.) From e8c29e6076382b58d6cc5e6386ddf281c56c0d64 Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Wed, 19 Nov 2014 13:23:01 -0800 Subject: [PATCH 10/12] move testing to contributing.md --- CONTRIBUTING.md | 6 ++++++ README.md | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db91cf06..16cbdd3e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,7 @@ #Contributing +# Setting Up Development Environment + ### 1 Fork and clone the repository. ### 2 Install Vagrant. @@ -16,3 +18,7 @@ run rake db:fix_accents to clean up encoding problems in the safe2p ### 5 Assets * [Assets Repo](https://github.com/RefugeRestrooms/refuge_assets) +## Testing + +Please cover any new code with specs. We prefer code to be covered using RSpec or Capybara. + diff --git a/README.md b/README.md index b1a6756b..60a24c52 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,6 @@ Here are the steps to deploy: * run any migrations `heroku run rake db:migrate --remote production` -### Testing - -Please cover any new code with specs. We prefer code to be covered using RSpec or Capybara. - - - ## Tech * Ruby Version - ruby-2.0.0-p247 From fe749427b1a4b8f3c89b1008ebd2906d05e962ef Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Wed, 19 Nov 2014 14:39:59 -0800 Subject: [PATCH 11/12] check for vagrant role in postgres and add bundle exec to rake command --- script/setup_vagrant.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/script/setup_vagrant.sh b/script/setup_vagrant.sh index 7ccedabd..5d554e02 100644 --- a/script/setup_vagrant.sh +++ b/script/setup_vagrant.sh @@ -69,12 +69,14 @@ else gem install bundler --no-rdoc --no-ri -q fi echo 'Running bundle install...' -bundle install +bundle install --gemfile=$REFUGE_PATH/Gemfile # Creating postres user -echo 'Creating vagrant postgres user...' -sudo -u postgres createuser vagrant --createdb --superuser +if ! psql -c 'SELECT rolname FROM pg_roles;' postgres | grep vagrant; then + echo 'Creating vagrant postgres user...' + sudo -u postgres createuser vagrant --createdb --superuser +fi # Seed db echo 'Seeding db...' -rake db:setup +bundle exec rake db:setup From 2d47bb7917fa4d8264d0b502d855b971fcb143fa Mon Sep 17 00:00:00 2001 From: Michael Wood Date: Sun, 23 Nov 2014 20:04:54 -0800 Subject: [PATCH 12/12] add pg_hba.conf changes --- CONTRIBUTING.md | 6 +- Vagrantfile | 5 +- config/database.yml | 2 +- setup/pg_hba.conf | 99 ++++++++++++++++++++++++++++++ {script => setup}/setup_vagrant.sh | 8 ++- 5 files changed, 113 insertions(+), 7 deletions(-) create mode 100644 setup/pg_hba.conf rename {script => setup}/setup_vagrant.sh (90%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 16cbdd3e..81d48416 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ -#Contributing +# Contributing -# Setting Up Development Environment +## Setting Up Development Environment ### 1 Fork and clone the repository. @@ -8,7 +8,7 @@ https://www.vagrantup.com/downloads ### 3 Capture the powers of vagrant - * In the repo dir: vagrant up + * In the repo dir: vagrant up (Safely ignore: 'dpkg-preconfigure: unable to re-open stdin: No such file or directory') * If changes have been made since running vagrant up: vagrant provision * To login to the machine: vagrant ssh diff --git a/Vagrantfile b/Vagrantfile index d207c031..9af219db 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -9,6 +9,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Ubuntu 14.04 base box config.vm.box = "ubuntu/trusty64" config.vm.hostname = BOXNAME + #config.vm.box_download_checksum = # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs @@ -26,7 +27,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # config.ssh.forward_agent = true # Share refuge repo in vagrant home folder - config.vm.synced_folder ".", "/home/vagrant/refugerestrooms" + config.vm.synced_folder ".", "/vagrant/refugerestrooms" # View virtualbox provider docs for more options config.vm.provider "virtualbox" do |vb| @@ -37,7 +38,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # If this gets bigger I can make it into a chef run # mi-wood - config.vm.provision "shell", path: "script/setup_vagrant.sh", privileged: false + config.vm.provision "shell", path: "setup/setup_vagrant.sh", privileged: false # Enable provisioning with chef solo, specifying a cookbooks path, roles # path, and data_bags path (all relative to this Vagrantfile), and adding diff --git a/config/database.yml b/config/database.yml index ff95246e..1bdf148e 100644 --- a/config/database.yml +++ b/config/database.yml @@ -3,7 +3,7 @@ development: encoding: unicode database: bathrooms_development pool: 5 - host: "" + host: localhost test: adapter: postgresql diff --git a/setup/pg_hba.conf b/setup/pg_hba.conf new file mode 100644 index 00000000..e2e88588 --- /dev/null +++ b/setup/pg_hba.conf @@ -0,0 +1,99 @@ +# PostgreSQL Client Authentication Configuration File +# =================================================== +# +# Refer to the "Client Authentication" section in the PostgreSQL +# documentation for a complete description of this file. A short +# synopsis follows. +# +# This file controls: which hosts are allowed to connect, how clients +# are authenticated, which PostgreSQL user names they can use, which +# databases they can access. Records take one of these forms: +# +# local DATABASE USER METHOD [OPTIONS] +# host DATABASE USER ADDRESS METHOD [OPTIONS] +# hostssl DATABASE USER ADDRESS METHOD [OPTIONS] +# hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] +# +# (The uppercase items must be replaced by actual values.) +# +# The first field is the connection type: "local" is a Unix-domain +# socket, "host" is either a plain or SSL-encrypted TCP/IP socket, +# "hostssl" is an SSL-encrypted TCP/IP socket, and "hostnossl" is a +# plain TCP/IP socket. +# +# DATABASE can be "all", "sameuser", "samerole", "replication", a +# database name, or a comma-separated list thereof. The "all" +# keyword does not match "replication". Access to replication +# must be enabled in a separate record (see example below). +# +# USER can be "all", a user name, a group name prefixed with "+", or a +# comma-separated list thereof. In both the DATABASE and USER fields +# you can also write a file name prefixed with "@" to include names +# from a separate file. +# +# ADDRESS specifies the set of hosts the record matches. It can be a +# host name, or it is made up of an IP address and a CIDR mask that is +# an integer (between 0 and 32 (IPv4) or 128 (IPv6) inclusive) that +# specifies the number of significant bits in the mask. A host name +# that starts with a dot (.) matches a suffix of the actual host name. +# Alternatively, you can write an IP address and netmask in separate +# columns to specify the set of hosts. Instead of a CIDR-address, you +# can write "samehost" to match any of the server's own IP addresses, +# or "samenet" to match any address in any subnet that the server is +# directly connected to. +# +# METHOD can be "trust", "reject", "md5", "password", "gss", "sspi", +# "krb5", "ident", "peer", "pam", "ldap", "radius" or "cert". Note that +# "password" sends passwords in clear text; "md5" is preferred since +# it sends encrypted passwords. +# +# OPTIONS are a set of options for the authentication in the format +# NAME=VALUE. The available options depend on the different +# authentication methods -- refer to the "Client Authentication" +# section in the documentation for a list of which options are +# available for which authentication methods. +# +# Database and user names containing spaces, commas, quotes and other +# special characters must be quoted. Quoting one of the keywords +# "all", "sameuser", "samerole" or "replication" makes the name lose +# its special character, and just match a database or username with +# that name. +# +# This file is read on server startup and when the postmaster receives +# a SIGHUP signal. If you edit the file on a running system, you have +# to SIGHUP the postmaster for the changes to take effect. You can +# use "pg_ctl reload" to do that. + +# Put your actual configuration here +# ---------------------------------- +# +# If you want to allow non-local connections, you need to add more +# "host" records. In that case you will also need to make PostgreSQL +# listen on a non-local interface via the listen_addresses +# configuration parameter, or via the -i or -h command line switches. + + + + +# DO NOT DISABLE! +# If you change this first entry you will need to make sure that the +# database superuser can access the database using some other method. +# Noninteractive access to all databases is required during automatic +# maintenance (custom daily cronjobs, replication, and similar tasks). +# +# Database administrative login by Unix domain socket +local all postgres peer + +# TYPE DATABASE USER ADDRESS METHOD + +# "local" is for Unix domain socket connections only +local all all trust +# IPv4 local connections: +host all all 127.0.0.1/32 trust +# IPv6 local connections: +host all all ::1/128 trust +# Allow replication connections from localhost, by a user with the +# replication privilege. +#local replication postgres peer +#host replication postgres 127.0.0.1/32 md5 +#host replication postgres ::1/128 md5 diff --git a/script/setup_vagrant.sh b/setup/setup_vagrant.sh similarity index 90% rename from script/setup_vagrant.sh rename to setup/setup_vagrant.sh index 5d554e02..499aeb18 100644 --- a/script/setup_vagrant.sh +++ b/setup/setup_vagrant.sh @@ -3,7 +3,7 @@ # It's only tested with ubuntu 14.04 set -e -REFUGE_PATH=$HOME/refugerestrooms +REFUGE_PATH=/vagrant/refugerestrooms # required packages declare -A packages @@ -71,6 +71,12 @@ fi echo 'Running bundle install...' bundle install --gemfile=$REFUGE_PATH/Gemfile +# Change permissions on pg_hba.conf +pg_hba=/etc/postgresql/9.3/main/pg_hba.conf +sudo cp /vagrant/refugerestrooms/setup/pg_hba.conf $pg_hba +sudo chown postgres:postgres $pg_hba +sudo chmod 640 $pg_hba + # Creating postres user if ! psql -c 'SELECT rolname FROM pg_roles;' postgres | grep vagrant; then echo 'Creating vagrant postgres user...'