Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Vagrant Configuration
#!/bin/bash
# CHEF CLIENT
apt-get update
apt-get install chef
# Set up remote chef-solo
mkdir -p /srv/chef-solo
install -d -o vagrant -g vagrant /srv/chef-solo
source /home/vagrant/devenvpy3k/bin/activate
export DJANGO_SETTINGS_MODULE="settings"
cd /vagrant/
package "python-pip"
package "python-setuptools"
package "python-dev"
package "python3-dev"
package "git"
package "python-pip"
script "extend_bashrc" do
user "vagrant"
cwd "/home/vagrant/"
interpreter "bash"
code <<-EOH
echo "if [ -f ~/.bash_vagrant ]; then\n . ~/.bash_vagrant\nfi" >> .bashrc
touch provisioned.lock
EOH
not_if do FileTest.file?("/home/vagrant/provisioned.lock") end
end
cookbook_file "/home/vagrant/.bash_aliases" do
user "vagrant"
group "vagrant"
mode "0770"
source "bash_aliases"
end
cookbook_file "/home/vagrant/.bash_vagrant" do
user "vagrant"
group "vagrant"
mode "0770"
source "bash_vagrant"
end
#
# Target OS Ubuntu Server 14.04 Trusty
# Chef 11.8.2
# Author: danigosa
# Date: 17/04/2014
#
#
include_recipe "provision::common"
##########################################################
# INSTALL VIRTUALENV
##########################################################
execute "install-virtualenv" do
user "root"
cwd "root"
command "pip install virtualenv"
action :run
end
execute "create-virtualenv-py2k" do
user "vagrant"
cwd "/home/vagrant"
command "virtualenv devenv"
action :run
end
execute "create-virtualenv-py3k" do
user "vagrant"
cwd "/home/vagrant"
command "virtualenv -p /usr/bin/python3 devenvpy3k"
action :run
end
##########################################################
# DJANGO SETUP
##########################################################
script "django-installation-py2k" do
user "vagrant"
cwd "/vagrant/"
interpreter "bash"
code <<-EOH
source /home/vagrant/devenv/bin/activate
pip install -r /vagrant/requirements/dev.txt
deactivate
EOH
end
script "django-installation-py3k" do
user "vagrant"
cwd "/vagrant/"
interpreter "bash"
code <<-EOH
source /home/vagrant/devenvpy3k/bin/activate
pip install -r /vagrant/requirements/dev.txt
deactivate
EOH
end
script "django-app-setup" do
user "root"
cwd "/vagrant/"
interpreter "bash"
code <<-EOH
find . -name '*.pyc' -delete
mkdir -p logs
chmod +x logs
touch logs/django.log
touch logs/django_request.log
EOH
end
# -*- 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 = "django-simple-seo"
config.vm.provision :shell, :path => "./vagrant/bootstrap.sh"
config.vm.box_url = "https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box"
config.vm.network "forwarded_port", guest: 8000, host: 8000
config.vm.network "forwarded_port", guest: 8888, host: 8888
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "./vagrant/cookbooks"
chef.add_recipe "provision::simple-seo"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.