Skip to content

Commit

Permalink
copy from bitbucket
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart Arickx committed Jan 6, 2016
1 parent 2ce61d4 commit 4250dac
Show file tree
Hide file tree
Showing 5 changed files with 268 additions and 48 deletions.
42 changes: 24 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Drupical is an easily configurable Vagrant box for developing Drupal projects.
The Vagrant box comes with the following software:

- Ubuntu 12.04 LTS 64
- PHP 5.5, 5.4 or 5.3
- Ubuntu 14.04 LTS 64
- PHP 5.3 (Ubuntu 12.04 LTS 64 / precise64)
- PHP 5.5 (Ubuntu 14.04 LTS 64 / trusty64)
- MySQL5
- Apache2
- Solr
Expand All @@ -17,7 +19,6 @@ The Vagrant box comes with the following software:
- Nodejs
- Grunt
- Ruby2
- Selenium
- OpenSSL

## Quickstart
Expand All @@ -44,7 +45,7 @@ In `local.vagrant.settings.json`:
### 3. Provision the box

```bash
make install
rake
```

## Installation
Expand Down Expand Up @@ -81,14 +82,19 @@ The most important configuration options are:
Property | Default | Description
---------|---------|------------
box_name | drupal | The name identifying your Vagrant box
box_type | oa/drupical-trusty64-base | Choose ubuntu flavor, oa/drupical-trusty64-base / oa/drupical-precise64-base
box_url | http://192.168.13.241/one-agency/drupical/trusty64/drupical-trusty64-base.php | http://192.168.13.241/one-agency/drupical/trusty64/drupical-trusty64-base.php / http://192.168.13.241/one-agency/drupical/precise64/drupical-precise64-base.php
vagrant_synced_folders | | A list of folders to sync with Vagrant
vhosts | | A list of apache2 vhosts
solr.solr_install | false | Include solr
solr.solr_version | 3.6.2 | The solr version
solr.solr_install | false | Install solr, possible values true / false
solr.solr_version | 3.6.2 / 4.10.4 | The solr version
rmdbs.root_password | 10moioui | The MySQL root user password
mysql.root_password | 10moioui | The MySQL root user password
varnish_install | true | Include varnish
php.php_version | 5.5 | The PHP version that will be installed
rmdbs.use-mysql-persistent-storage | false | Use persistent storage for mysql database, possible values true / false
varnish_install | true | Install varnish, possible values true / false
php.php_version | 5.x | The PHP version that will be installed
php.enable_php_phing | false | Install phing, possible values true / false
php.enable_php_composer | false | Install composer, possible values true / false
php.enable_php_drush | true | Install drush, possible values true / false

### Provisioning the Vagrant Box

Expand All @@ -97,7 +103,7 @@ Execute the following commands inside the vagrant folder.
OSX:

```bash
make install
rake
```

Ubuntu:
Expand All @@ -123,7 +129,7 @@ Command | Description
`vagrant ssh` | Log in via SSH
`vagrant halt` | Power off
`vagrant suspend` | Sleep
`vagrant destroy` | Remove the box (run `vagrant up --provision` to set it up again).
`vagrant destroy -f` | Remove the box (run `vagrant up --provision` to set it up again).

More information is available in the [official Vagrant documentation](https://docs.vagrantup.com/v2/cli/index.html).

Expand Down Expand Up @@ -164,14 +170,14 @@ If you prefer a native app like SequelPro follow these instructions:
Problem | Solution
--------|---------
Permission error on a log directory when booting. | On the host machine, remove all but the `.gitkeep` file in the `logs` directory and run `vagrant reload`.
mount.nfs: access denied error | On the host machine, run `sudo rm /etc/exports` and `vagrant reload`
403 / Forbidden error when visiting the site in a browser | Run `vagrant reload` on the host machine
No connection error when going to the website in a browser | SSH into the machine and run `sudo apache2ctl start`
Box in wrong state error | Run `vagrant destroy`, remove the .vagrant directory and check if there are corrupt devices that should be removed in VirtualBox -> File -> Virtual Media Manager
Network interface is defined twice | Use Vagrant 1.7.1
There was an error while executing `VBoxManage` | killall -9 VBoxHeadless && vagrant reload. If that fails, restart your machine.
Vagrant won't boot after cancelling vagrant up with cmd + c | restart your machine
Vagrant won't start: "A virtual machine with the name xxx123 already exists" | Run `vagrant destroy`, remove the .vagrant directory and check if there are corrupt devices that should be removed in VirtualBox -> File -> Virtual Media Manager
mount.nfs: access denied error | Run `rake emergency_fix:nfs`.
403 / Forbidden error when visiting the site in a browser | Run `rake core:reload`.
No connection error when going to the website in a browser | Run `rake maintenance:restart_apache` && `rake maintenance:restart_mysql`.
Box in wrong state error | Run `rake core:destroy`, remove the .vagrant directory and check if there are corrupt devices that should be removed in VirtualBox -> File -> Virtual Media Manager.
Network interface is defined twice | Install most recent version of vagrant.
There was an error while executing `VBoxManage` | Run `rake emergency_fix:forcekill` && `rake core:reload`. If that fails, restart your machine.
Vagrant won't boot after cancelling vagrant up with cmd + c | Run `rake emergency_fix:forcekill` && `rake core:reload`. If that fails, restart your machine.
Vagrant won't start: "A virtual machine with the name xxx123 already exists" | Run `rake core:destroy`, remove the .vagrant directory and check if there are corrupt devices that should be removed in VirtualBox -> File -> Virtual Media Manager.



Expand Down
228 changes: 228 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

desc "default=up"
task :default do

Rake::Task["core:up"].invoke()

end

namespace :core do

desc "up"
task :up do
puts "up"
begin
sh "ssh-add -K ~/.ssh/id_rsa && vagrant up"
rescue
end
end

desc "halt"
task :halt do
begin
sh "vagrant halt"
rescue
end
end

desc "suspend"
task :suspend do
begin
sh "vagrant suspend"
rescue
end
end

desc "reload"
task :reload do
begin
sh "vagrant reload"
rescue
end
end

desc "up_rsync"
task :up_rsync do
begin
sh "ssh-add -K ~/.ssh/id_rsa && vagrant up"
sh "vagrant rsync-auto"
rescue
end
end

desc "ssh"
task :ssh do
begin
sh "vagrant ssh"
rescue
end
end

desc "destroy"
task :destroy do
begin
sh "vagrant destroy -f"
rescue
end
end

end

namespace :share do

desc "web"
task :web do
sh "vagrant login && vagrant share --http 80 --https 443"
end

desc "ssh"
task :ssh do
sh "vagrant login && vagrant share --ssh"
end

desc "all"
task :full do
sh "vagrant login && vagrant share --http 80 --https 443 --ssh"
end

end

namespace :environment do

desc "install vagrant dependencies"
task :install_dependencies_vagrant do
sh "vagrant plugin install vagrant-cachier --plugin-version '1.2.0'"
sh "vagrant plugin install vagrant-hostsupdater --plugin-version '0.0.11'"
sh "vagrant plugin install vagrant-omnibus --plugin-version '1.4.1'"
sh "vagrant plugin install vagrant-persistent-storage --plugin-version '0.0.16'"
sh "vagrant plugin install vagrant-reload --plugin-version '0.0.1'"
sh "vagrant plugin install vagrant-share --plugin-version '1.1.4'"
sh "vagrant plugin install vagrant-triggers --plugin-version '0.5.0'"
sh "vagrant plugin install vagrant-vbguest --plugin-version '0.10.0'"
end

end

namespace :maintenance do

desc "clear_logs"
task :clear_logs do
Rake::Task["core:up"].invoke()
sh "vagrant ssh --command 'sudo rm -rf /var/log/*'"
sh "vagrant ssh --command 'sudo mkdir /var/log/apache2 ; sudo mkdir /var/log/mysql'"
Rake::Task["core:reload"].invoke()
end

desc "restart_apache"
task :restart_apache do
sh "vagrant ssh --command 'sudo service apache restart'"
end

desc "restart_mysql"
task :restart_mysql do
sh "vagrant ssh --command 'sudo service mysql restart'"
end

desc "shrink"
task :shrink do

begin
require 'json'
load 'include/helper.rb'
vconfig = vagrant_get_config()
box_hostname = vconfig['config']['box_hostname'].split('.')[0]
rescue
LoadError
end

Rake::Task["core:up"].invoke()

begin
sh "vagrant ssh --command 'sudo rm -rf /var/log/*'"
sh "vagrant ssh --command 'sudo mkdir /var/log/apache2 ; sudo mkdir /var/log/mysql'"
Rake::Task["core:reload"].invoke()
rescue
end

begin
sh "vagrant ssh --command 'sudo cat /dev/zero > zero.fill'"
rescue
sh "vagrant ssh --command 'sudo sync;sleep 1;sudo sync;'"
sh "vagrant ssh --command 'sudo rm -f zero.fill'"
end

begin
Rake::Task["core:halt"].invoke()
sh "tar -cvzf ~/VirtualBox\\ VMs/"+ box_hostname + ".tar.gz ~/VirtualBox\\ VMs/"+ box_hostname
Rake::Task["core:up"].invoke()
sh "VBoxManage storageattach " + box_hostname + " --storagectl SATAController --port 0 --device 0 --type hdd --medium none"
sh "VBoxManage clonehd --format VDI ~/VirtualBox\\ VMs/"+ box_hostname +"/box-disk1.vmdk /tmp/box-disk1.vdi"
sh "VBoxManage closemedium disk ~/VirtualBox\\ VMs/"+ box_hostname +"/box-disk1.vmdk --delete"
sh "VBoxManage modifyhd /tmp/box-disk1.vdi --compact"
sh "VBoxManage clonehd --format vmdk /tmp/box-disk1.vdi ~/VirtualBox\\ VMs/"+ box_hostname +"/box-disk1.vmdk"
sh "VBoxManage closemedium disk /tmp/box-disk1.vdi --delete"
sh "VBoxManage storageattach " + box_hostname + " --storagectl SATAController --port 0 --device 0 --type hdd --medium ~/VirtualBox\\ VMs/"+ box_hostname +"/box-disk1.vmdk"
sh "rm -rf ~/VirtualBox\\ VMs/"+ box_hostname + ".tar.gz"
rescue
Rake::Task["core:halt"].invoke()
sh "tar -xvzf ~/VirtualBox\\ VMs/"+ box_hostname + ".tar.gz ~/VirtualBox\\ VMs/"+ box_hostname
end

Rake::Task["core:reload"].invoke()

end

end

namespace :emergency_fix do

desc "nfs"
task :nfs do

Rake::Task["core:halt"].invoke()

begin
sh "sudo rm -f /etc/exports"
rescue
end

begin
for i in 0..20
sh "vboxmanage hostonlyif remove vboxnet#{i}"
end
rescue
end

Rake::Task["core:up"].invoke()

begin
sh "vagrant hostsupdater"
rescue
end

end

desc "forcekill"
task :forcekill do

begin
begin
sh "sudo killall -9 vagrant"
rescue
end
begin
sh "sudo killall -9 VBoxHeadless"
rescue
end
begin
sh "sudo killall -9 ruby"
rescue
end
rescue
end

end

end
28 changes: 14 additions & 14 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

#
config.vm.box = vconfig['config']['box_type']
config.vm.box_check_update = true
config.vm.box_check_update = false
config.vm.box_url = vconfig['config']['box_url']
#
# config.omnibus.chef_version = '12'
Expand Down Expand Up @@ -172,19 +172,19 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
chef.roles_path = 'chef-repo/roles'

#
#if vconfig['config']['solr']['solr_install']
# chef.add_role('web-solr')
#end
#
##
#if vconfig['config']['varnish_install']
# chef.add_role('web-varnish')
#end
#
##
#if vconfig['config']['memcached_install']
# chef.add_role('web-memcached')
#end
if vconfig['config']['solr']['solr_install']
chef.add_role('web-solr')
end

#
if vconfig['config']['varnish_install']
chef.add_role('web-varnish')
end

#
if vconfig['config']['memcached_install']
chef.add_role('web-memcached')
end

#
chef.add_role('project')
Expand Down
14 changes: 0 additions & 14 deletions bin/host/cleanup_interfaces.sh

This file was deleted.

4 changes: 2 additions & 2 deletions default.vagrant.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"vagrant_debugging": false,

"box_type": "oa/drupical-trusty64-base",
"box_url": "http://192.168.13.241/one-agency/drupical/trusty64/drupical-trusty64-base.json",
"box_url": "http://192.168.13.241/one-agency/drupical/trusty64/drupical-trusty64-base.php",

//"box_type": "oa/drupical-precise64-base",
//"box_url": "http://192.168.13.241/one-agency/drupical/precise64/drupical-precise64-base.json",
//"box_url": "http://192.168.13.241/one-agency/drupical/precise64/drupical-precise64-base.php",

"box_name": "drupal",
"box_hostname": "dev",
Expand Down

0 comments on commit 4250dac

Please sign in to comment.