Skip to content
Permalink
Browse files

Add Vagrantfile

  • Loading branch information...
firstred committed May 21, 2017
1 parent 4d63883 commit 5bae71d6cecb3f436f02c410bc8e59664ee18006
@@ -0,0 +1,101 @@
# Optimized for Vagrant 1.7 and above.
Vagrant.require_version ">= 1.7.0"

# 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.Vagrant.configure(2) do |config|

config.vm.box = "bento/ubuntu-16.04"
# The hostname for the VM
config.vm.hostname = "thirty.bees"

# 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

# Disable the new default behavior introduced in Vagrant 1.7, to
# ensure that all Vagrant machines will use the same SSH key pair.
# See https://github.com/mitchellh/vagrant/issues/5005
config.ssh.insert_key = false

# If true, then any SSH connections made will enable agent forwarding.
# Default value: false
config.ssh.forward_agent = false

# Create an entry in the /etc/hosts file for #{hostname}
if defined? VagrantPlugins::HostsUpdater
config.hostsupdater.aliases = ["#{config.vm.hostname}"]
end

config.vm.provider "virtualbox" do |v,override|
# 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
v.gui=false

# Memory
v.customize ["modifyvm", :id, "--memory", 1024]

# CPUs
v.customize ["modifyvm", :id, "--cpus", "1"]

# Video Ram
v.customize ["modifyvm", :id, "--vram", "32"]

# --hwvirtex on|off: This enables or disables the use of hardware virtualization
# extensions (Intel VT-x or AMD-V) in the processor of your host system;
v.customize ["modifyvm", :id, "--hwvirtex", "on"]

# --hpet on|off: This enables/disables a High Precision Event Timer (HPET)
# which can replace the legacy system timers. This is turned off by default.
# Note that Windows supports a HPET only from Vista onwards.
v.customize ["modifyvm", :id, "--hpet", "on"]

# --pagefusion on|off: Enables/disables (default) the Page Fusion feature.
# The Page Fusion feature minimises memory duplication between VMs with similar
# configurations running on the same host. See Section 4.9.2, “Page Fusion” for details.
v.customize ["modifyvm", :id, "--pagefusion", "on"]

# --paravirtprovider none|default|legacy|minimal|hyperv|kvm: This setting specifies which
# paravirtualization interface to provide to the guest operating system.
v.customize ["modifyvm", :id, "--paravirtprovider", "kvm"]

# --chipset piix3|ich9: By default VirtualBox emulates an Intel PIIX3 chipset.
v.customize ["modifyvm", :id, "--chipset", "ich9"]

v.customize ["setextradata", "global", "GUI/MaxGuestResolution", "any"]
v.customize ["setextradata", :id, "CustomVideoMode1", "1024x768x32"]
v.customize ["modifyvm", :id, "--ioapic", "on"]
v.customize ["modifyvm", :id, "--rtcuseutc", "on"]
v.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
v.customize ["modifyvm", :id, "--audio", "none"]
end

# Run Ansible from the Vagrant VM
config.vm.provision "ansible_local" do |ansible|
ansible.verbose = "vv"
ansible.playbook = "vagrant/playbooks/vagrant.yml"
end

config.vm.network "private_network", ip: "10.0.0.30"
end
@@ -0,0 +1,8 @@
- name: Install required base packages
apt: name={{ item }} state=present
with_items:
- curl
- git
- python-mysqldb
- zip
- unzip
@@ -0,0 +1,3 @@
---
- name: Install MySQL
apt: name=mysql-server state=present
@@ -0,0 +1,2 @@
- name: restart nginx
service: name=nginx state=restarted
@@ -0,0 +1,17 @@
---
- name: Install nginx
apt: name=nginx state=present

- name: Copy across new nginx config
template:
src=nginx.conf.j2
dest=/etc/nginx/nginx.conf
notify:
- restart nginx

- name: Remove default virtual host
file:
path=/etc/nginx/sites-enabled/default
state=absent
notify:
- restart nginx
@@ -0,0 +1,73 @@
user {{ www_user }};
worker_processes 4;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;
gzip_disable "msie6";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##

#include /etc/nginx/naxsi_core.rules;

##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##

#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
@@ -0,0 +1,3 @@
---
- name: Download and install PHPUnit
get_url: url=https://phar.phpunit.de/phpunit.phar dest=/usr/local/bin/phpunit mode=0755
@@ -0,0 +1,2 @@
- name: restart php-fpm
service: name=php{{ php_version }}-fpm state=restarted
@@ -0,0 +1,3 @@
---
dependencies:
- { role: php }
@@ -0,0 +1,3 @@
---
- name: Install php-fpm
apt: name=php{{ php_version }}-fpm state=present
@@ -0,0 +1,3 @@
---
php_version: 7.0
composer_process_timeout: 900
@@ -0,0 +1,48 @@
---
- name: Add apt key for PHP ppa
apt_key:
keyserver: keyserver.ubuntu.com
id: 14AA40EC0831756756D7F66C4F4EA0AAE5267A6C
state: present

- name: Add apt repository for PHP
apt_repository: repo='ppa:ondrej/php/ubuntu'

- name: Install python-software-properties
apt: name=python-software-properties state=present

- name: Install PHP
apt: name=php{{ php_version }} state=present

- name: Install required php packages
apt: name={{ item }} state=present
with_items:
- php{{ php_version }}-bcmath
- php{{ php_version }}-cli
- php{{ php_version }}-common
- php{{ php_version }}-curl
- php{{ php_version }}-dom
- php{{ php_version }}-gd
- php{{ php_version }}-imap
- php-imagick
- php{{ php_version }}-imap
- php{{ php_version }}-intl
- php{{ php_version }}-json
- php{{ php_version }}-mbstring
- php{{ php_version }}-mcrypt
- php{{ php_version }}-mysql
- php{{ php_version }}-opcache
- php{{ php_version }}-readline
- php-redis
- php{{ php_version }}-soap
- php{{ php_version }}-xml
- php{{ php_version }}-zip

- name: Enable the MCrypt extension
shell: phpenmod mcrypt

- name: Install composer
shell: curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

- name: Configure composer cache directory to avoid using slow NFS
shell: composer config --global cache-dir /dev/shm/composer/cache
@@ -0,0 +1,6 @@
---
dependencies:
- { role: base }
- { role: mysql }
- { role: php-fpm }
- { role: nginx }
@@ -0,0 +1,35 @@
---
- name: Create MySQL database for thirtybees
mysql_db: name=thirtybees state=present

- name: Create MySQL user for thirtybees
mysql_user: name=thirtybees password=thirtybees priv=*.*:ALL state=present

- name: Install thirty bees itself
shell: php ./install-dev/index_cli.php --domain=thirty.bees --db_user=thirtybees --db_password=thirtybees --db_name=thirtybees --db_create --name="thirty bees" --firstname=thirty --lastname=bees --email=test@thirty.bees --password=thirtybees --newsletter=0
become: true
become_user: "{{ www_user }}"
args:
chdir: /vagrant

- name: Copy across new php-fpm pool config for thirtybees
template:
src=php-fpm.conf.j2
dest=/etc/php/{{ php_version }}/fpm/pool.d/thirtybees.conf
notify:
- restart php-fpm

- name: Copy across new virtual host for thirtybees
template:
src=nginx.conf.j2
dest=/etc/nginx/sites-available/thirtybees.conf
notify:
- restart nginx

- name: Enable new vagrant virtual host for thirtybees
file:
src=/etc/nginx/sites-available/thirtybees.conf
dest=/etc/nginx/sites-enabled/thirtybees.conf
state=link
notify:
- restart nginx
@@ -0,0 +1,58 @@
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

server_name thirty.bees;

root /vagrant;

error_page 405 =200 $uri;
index index.php index.html;

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
auth_basic off;
allow all;
log_not_found off;
access_log off;
}

##
# Gzip Settings
##

gzip off;

rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
rewrite ^/([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2$3.jpg last;
rewrite ^/([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last;
rewrite ^/([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(\-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last;
if (!-e $request_filename) {
rewrite ^/.*$ /index.php last;
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_keep_conn on;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php-thirtybees.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
fastcgi_read_timeout 60m;
fastcgi_send_timeout 60m;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
}

0 comments on commit 5bae71d

Please sign in to comment.
You can’t perform that action at this time.