Skip to content

Commit

Permalink
Added vagrant configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
whisller committed Jan 20, 2013
1 parent 67eb531 commit 2df2441
Show file tree
Hide file tree
Showing 5 changed files with 160 additions and 0 deletions.
1 change: 1 addition & 0 deletions public/dev.php
Expand Up @@ -18,6 +18,7 @@

if (!in_array(@$_SERVER['REMOTE_ADDR'], array(
'127.0.0.1',
'172.44.44.1',
'::1',
))) {
header('HTTP/1.0 403 Forbidden');
Expand Down
1 change: 1 addition & 0 deletions vagrant/.vagrant
@@ -0,0 +1 @@
{"active":{"default":"9d1d2463-cece-47dc-b8e5-d5ca1241e4eb"}}
32 changes: 32 additions & 0 deletions vagrant/Vagrantfile
@@ -0,0 +1,32 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant::Config.run 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 = "precise32"
config.vm.host_name = "sylius"

# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "http://files.vagrantup.com/precise32.box"

config.vm.network :hostonly, "172.44.44.44"
config.vm.share_folder "v-root", "/mnt/sylius", ".." , :nfs => true
# whithout this symlinks can't be created on the shared folder
config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]

# chef solo configuration
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "./"
# chef debug level, start vagrant like this to debug:
# $ CHEF_LOG_LEVEL=debug vagrant <provision or up>
chef.log_level = ENV['CHEF_LOG'] || "info"

# chef recipes
chef.add_recipe("cookbook")
end
end
114 changes: 114 additions & 0 deletions vagrant/cookbook/recipes/default.rb
@@ -0,0 +1,114 @@
# Run apt-get update to create the stamp file
execute "apt-get-update" do
command "apt-get update"
ignore_failure true
not_if do ::File.exists?('/var/lib/apt/periodic/update-success-stamp') end
end

# For other recipes to call to force an update
execute "apt-get update" do
command "apt-get update"
ignore_failure true
action :nothing
end

# provides /var/lib/apt/periodic/update-success-stamp on apt-get update
package "update-notifier-common" do
notifies :run, resources(:execute => "apt-get-update"), :immediately
end

execute "apt-get-update-periodic" do
command "apt-get update"
ignore_failure true
only_if do
File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
File.mtime('/var/lib/apt/periodic/update-success-stamp') < Time.now - 86400
end
end

# install the software we need
%w(
mysql-server
curl
apache2
libapache2-mod-php5
git
php5-cli
php5-curl
php5-sqlite
php5-intl
php-apc
php5-mysql
).each { | pkg | package pkg }

template "/etc/apache2/sites-enabled/vhost.conf" do
user "root"
mode "0644"
source "vhost.conf.erb"
notifies :reload, "service[apache2]"
end

service "apache2" do
supports :restart => true, :reload => true, :status => true
action [ :enable, :start ]
end

execute "check if short_open_tag is Off in /etc/php5/apache2/php.ini?" do
user "root"
not_if "grep 'short_open_tag = Off' /etc/php5/apache2/php.ini"
command "sed -i 's/short_open_tag = On/short_open_tag = Off/g' /etc/php5/apache2/php.ini"
end

execute "check if short_open_tag is Off in /etc/php5/cli/php.ini?" do
user "root"
not_if "grep 'short_open_tag = Off' /etc/php5/cli/php.ini"
command "sed -i 's/short_open_tag = On/short_open_tag = Off/g' /etc/php5/cli/php.ini"
end

execute "check if date.timezone is Europe/Paris in /etc/php5/apache2/php.ini?" do
user "root"
not_if "grep '^date.timezone = Europe/Paris' /etc/php5/apache2/php.ini"
command "sed -i 's/;date.timezone =.*/date.timezone = Europe\\/Paris/g' /etc/php5/apache2/php.ini"
end

execute "check if date.timezone is Europe/Paris in /etc/php5/cli/php.ini?" do
user "root"
not_if "grep '^date.timezone = Europe/Paris' /etc/php5/cli/php.ini"
command "sed -i 's/;date.timezone =.*/date.timezone = Europe\\/Paris/g' /etc/php5/cli/php.ini"
end

execute "preparing parameters.yml file" do
command "cp /mnt/sylius/sandbox/config/container/parameters.yml.dist /mnt/sylius/sandbox/config/container/parameters.yml"
end

execute "doctrine:database:drop" do
command "/mnt/sylius/sandbox/console doctrine:database:drop --force"
end

execute "doctrine:database:create" do
command "/mnt/sylius/sandbox/console doctrine:database:create"
end

execute "doctrine:schema:create" do
command "/mnt/sylius/sandbox/console doctrine:schema:create --em=default"
end

execute "doctrine:fixtures:load" do
command "/mnt/sylius/sandbox/console doctrine:fixtures:load"
end

execute "assetic:dump" do
command "/mnt/sylius/sandbox/console assetic:dump"
end

bash "Running composer install and preparing the Sylius repository" do
not_if "test -e /vagrant/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/public"
user "vagrant"
cwd "/mnt/sylius"
code <<-EOH
set -e
ln -sf /var/tmp/vendor
curl -s https://getcomposer.org/installer | php
COMPOSER_VENDOR_DIR="/var/tmp/vendor" php composer.phar install
EOH
end
12 changes: 12 additions & 0 deletions vagrant/cookbook/templates/default/vhost.conf.erb
@@ -0,0 +1,12 @@
# Override the Apache User (vhosts are included at the end of apache2.conf)
User vagrant
Group vagrant

<VirtualHost *:80>
Servername sylius.lo
Serveralias 172.44.44.44
DocumentRoot /mnt/sylius/public
<Directory "/mnt/sylius/public">
AllowOverride All
</Directory>
</VirtualHost>

0 comments on commit 2df2441

Please sign in to comment.