VAW (Vagrant Ansible WordPress) is Ansible playbooks for website developer, webmaster and WordPress theme/plugin developer.
Ruby Shell
Permalink
Failed to load latest commit information.
command fix command Oct 3, 2016
config.sample.tuning
config
group_vars
hosts change provision to ansible_local from inline shell Aug 4, 2016
import
plugins initial commit Dec 22, 2014
roles
spec
themes initial commit Dec 22, 2014
.gitignore fix gitignore Sep 9, 2016
Rakefile
Vagrantfile fix the inline script to get the major version number Oct 3, 2016
readme-ja.md version 0.4.2 Oct 4, 2016
readme.md version 0.4.2 Oct 4, 2016
site.yml version 0.4.2 Oct 4, 2016

readme.md

VAW (Vagrant Ansible WordPress)

VAW (Vagrant Ansible WordPress) is Ansible playbooks for website developer, webmaster and WordPress theme/plugin developer.

Launch the development environment in Vagrant, you can build the website and verify the operation of the website. Of course, you can also develop WordPress themes and plugins.

VAW is also a collaboration tool. You can take advantage of collaboration tool that share the environment with development partners, designers and client.

Features

1. Build Server and Database environment

VAW will build server from Apache or nginx, and build database from MySQL, MariaDB or Percona MySQL.

Server nginx is a FastCGI configuration as a reverse proxy. And building a PHP execution environment from PHP-FPM (FastCGI Process Manager) or HHVM (HipHop Virtual Machine).

By default, the server and the databese is installed in the default settings. Also you can edit configuration files.

You can validate on the server and the database of various combinations.

2. Build WordPress environment

VAW will build a WordPress which has been processed in a variety of settings and data.

You can verify the test data or real data on WordPress. VAW will realize building of WordPress synchronized with the data and files in the production environment.

  • Install specified version WordPress Core
  • Install WordPress Core in Your Language
  • Install to specified directory, or subdirectory install
  • Multisite support
  • Administration Over SSL support
  • Install theme
    • Automatic activate
    • Batch install multiple themes
    • Install the theme in the local path (developing theme and official directory unregistered theme support)
  • Install plugin
    • Automatic activate
    • Batch install multiple plugins
    • Install the plugin in the local path (developing plugin and official directory unregistered plugin support)
  • Setting theme_mod (theme modification value) and Options
  • Setting permalink structure
  • Importing data from any one of three ways
    • WordPress export (WXR) file
    • SQL file (database dump data)
    • Theme Unit Test
  • Automatic placement to wp-content of uploads directory
  • Replacement to the URL of the test environment from the URL of the production environment
  • Regenerate thumbnails

3. Develop & Deploy Tools

Pre-installing PHP version managment 'phpenv', Dependency Manager for PHP 'Composer', command-line tools for WordPress 'WP-CLI' and version control system 'Git' in the standard.

You can install the develop tools or the deploy tools by usage. See Specification for list of installed tools.

Requirements

Usage

1. Install Virtualbox

Download the VirtualBox form www.virtualbox.org and install.

2. Install Vagrant

Download the Vagrant form www.vagrantup.com and install.

3. Install Vagrant plugin

Install the Vagrant plugin on the terminal as necessary.

vagrant plugin install vagrant-hostsupdater
vagrant plugin install vagrant-cachier
vagrant plugin install vagrant-vbguest
vagrant plugin install vagrant-serverspec

4. Download Ansible playbooks of VAW

Download a Vagrantfile and Ansible playbooks from the following link.

Download Zip format file

5. Launch a virtual environment

cd vaw-x.x.x
vagrant up

If you don't have a Box at first, begins from the download of Box. After provisioning, you can launch a WordPress environment.

6. Access to the website and the WordPress Admin

Access to the website http://vaw.local/. Access to the WordPress admin http://vaw.local/wp-admin/.

Default configuration Variables

ID and password for the initial setting is as follows. Can be set in the provisioning configuration file.

Database

  • ROOT PASSWORD admin
  • HOST localhost
  • DATABASE NAME wordpress
  • USER admin
  • PASSWORD admin

WordPress Admin

  • USER admin
  • PASSWORD admin

Customize Options

You can build a variety of environment that edit the configuration file of VAW.

There are two configuration files you can customize.

Run vagrant up or vagrant provision, after editing the configuration file.

Vagrant configuration file (Ruby)

Vagrant configuration file is Vagrantfile.

Vagrantfile will set the vagrant Box, private IP address, hostname and the document root.

If you launch multiple environments, change the name of the directory. Should rewrite vm_ip andvm_hostname. Note not to overlap with other environments.

You can accesse from a terminal in the same LAN to use the public network to Vagrant virtual environment. To use public networks, set IP address for bridged connection to public_ip. In that case, recommended that configure the same IP address to vm_hostname.

## Vagrant Settings ##
vm_box                = 'vaw/centos7-default'
vm_box_version        = '>= 0'
vm_ip                 = '192.168.46.49'
vm_hostname           = 'vaw.local'
vm_document_root      = '/var/www/html'

public_ip             = ''

vbguest_auto_update = false
  • vm_box (required) name of Vagrant Box (default: vaw/centos7-default)
  • vm_box_version (required) version of Vagrant Box (default: >= 0)
  • vm_ip (required) private IP address (default: 192.168.46.49)
  • vm_hostname (required) hostname (default: vaw.local)
  • vm_document_root (required) document root path (default: /var/www/html)
    • auto create wordpress directory and synchronized
  • public_ip IP address of bridged connection (default: ``)
  • vbguest_auto_update update VirtualBox Guest Additions (default: false / value: true | false)

Provisioning configuration file (YAML)

Provisioning configuration file is group_vars/all.yml.

In YAML format, you can set server, database and WordPress environment. And can enable the develop and deploy tools.

## Server & Database Settings ##

server             : 'apache'   # apache|nginx

# fastcgi is possible only server 'nginx'
fastcgi            : 'php-fpm'  # php-fpm|hhvm

database           : 'mysql'    # mysql|mariadb|percona
db_root_password   : 'admin'

db_host            : 'localhost'
db_name            : 'wordpress'
db_user            : 'admin'
db_password        : 'admin'
db_prefix          : 'wp_'

## WordPress Settings ##

title              : 'VAW (Vagrant Ansible WordPress)'
admin_user         : 'admin'
admin_password     : 'admin'
admin_email        : 'hoge@example.com'

# e.g. latest, 4.1, 4.1-beta1
# see Release Archive - https://wordpress.org/download/release-archive/
# 3.5.2 or later to work properly
version            : 'latest'

# e.g. en_US, ja
# see wordpress-i18n list - http://svn.automattic.com/wordpress-i18n/
lang               : 'en_US'

# in own directory or subdirectory install.
# see http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
wp_dir             : ''   #e.g. /wordpress
wp_site_path       : ''   #e.g. /wordpress

multisite          : false   # true|false
ssl_admin          : false   # true|false

# theme slug|url|zip (local path, /vagrant/themes/~.zip) |empty ('')
activate_theme     : ''
# themes             :
#                         - yoko
#                         - Responsive

# plugin slug|url|zip (local path, /vagrant/plugins/~.zip) |empty ('')
activate_plugins   :
                        - theme-check
                        - plugin-check
                        - log-deprecated-notices
                        - debug-bar
                        - query-monitor
                        - broken-link-checker
plugins            :
                        - developer
                        - monster-widget
                        - wordpress-beta-tester

# theme_mod          :
#                        background_color: 'cccccc'

# see Option Reference - http://codex.wordpress.org/Option_Reference
# options            :
#                        blogname: 'blog title'
#                        blogdescription: 'blog description'

# e.g. /%year%/%monthnum%/%postname%
# see http://codex.wordpress.org/Using_Permalinks
permalink_structure  :
                      structure   : ''
                      category    : ''
                      tag         : ''

# Any one of three ways to import
import_xml_data    : ''   # local path, /vagrant/import/~.xml
import_db_data     : ''   # local path, /vagrant/import/~.sql
theme_unit_test    : false   # true|false

replace_old_url         : ''   # to vm_hostname from old url
regenerate_thumbnails   : false   # true|false

## Develop & Deploy Settings ##

WP_DEBUG           : true    # true|false
SAVEQUERIES        : true    # true|false

php_version        : 7.0.7

develop_tools      : false   # true|false
deploy_tools       : false   # true|false

## That's all, stop setting. Let's vagrant up!! ##

WP_URL             : '{{ HOSTNAME }}{{ wp_site_path }}'
WP_PATH            : '{{ DOCUMENT_ROOT }}{{ wp_dir }}'

Server & Database Settings

  • server (required) name of web server (default: apache / value: apache | nginx)
  • fastcgi name of fastCGI (default: php-fpm / value: php-fpm | hhvm)
    • fastcgi is possible only server 'nginx'
  • database (required) name of databese (default: mysql / value: mysql | mariadb | percona)
  • db_root_password (required) database root password (default: admin)
  • db_host (required) database host (default: localhost)
  • db_name (required) name of database (default: wordpress)
  • db_user (required) database user name (default: admin)
  • db_password (required) database user password (default: admin)
  • db_prefix database prefix (default: wp_)

WordPress Settings

  • title WordPress site title (default: VAW (Vagrant Ansible WordPress))
  • admin_user (required) WordPress admin user name (default: admin)
  • admin_password (required) WordPress admin user password (default: admin)
  • admin_email (required) WordPress admin email address (default: hoge@example.com)
  • version (required) version of WordPress (default: latest)
    • e.g. latest, 4.1, 4.1-beta1
    • see Release Archive
    • version 3.5.2 or later to work properly
  • lang (required) WordPress in your language (default: en_US)

  • wp_dir directory path to subdirectory install WordPress (default: install to document root)

  • wp_site_path path of site (default: document root)

    • If wp_dir and wp_site_path are the same path, in own directory install.
    • If wp_dir and wp_site_path are different path, install to subdirectory. Note that wp_site_path be placed on one above the directory than wp_dir.
    • see Giving WordPress Its Own Directory
  • multisite Multisite enabled flag (default: false / value: true | false)

  • ssl_admin administration over SSL enabled flag (default: false / value: true | false)
  • activate_theme install a theme and activated (default: default theme)
    • set default theme '', theme slug, zip file URL or local zip file path
    • set /vagrant/themes/~.zip by local zip file path
  • themes install themes
    • set in YAML arrays of hashes format theme slug, zip file URL or local zip file path
    • set /vagrant/themes/~.zip by local zip file path
    • comment out with a # at the beginning of a line, if you want to disable the setting.

Configuration example

themes             :
                     - yoko
                     - Responsive

Disable the setting case

# themes             :
#                      - yoko
#                      - Responsive
  • activate_plugins install plagins and activated
    • set in YAML arrays of hashes format plagin slug, zip file URL or local zip file path
    • set /vagrant/plagins/~.zip by local zip file path
    • comment out with a # at the beginning of a line, if you want to disable the setting.

Configuration example

activate_plugins   :
                        - theme-check
                        - plugin-check

Disable the setting case

# activate_plugins   :
#                         - theme-check
#                         - plugin-check
  • plugins install plagins

    • set in YAML arrays of hashes format plagin slug, zip file URL or local zip file path
    • set /vagrant/plagins/~.zip by local zip file path
    • comment out with a # at the beginning of a line, if you want to disable the setting.
  • theme_mod setting theme_mod (theme modification value)

    • see set_theme_mod()
    • set in YAML nested hash format
    • comment out with a # at the beginning of a line, if you want to disable the setting.

Configuration example

theme_mod          :
                       background_color: 'cccccc'

Disable the setting case

# theme_mod          :
#                        background_color: 'cccccc'
  • options setting options
    • see update_option() and Option Reference
    • set in YAML nested hash format
    • comment out with a # at the beginning of a line, if you want to disable the setting.

Configuration example

options            :
                       blogname: 'blog title'
                       blogdescription: 'blog description'

Disable the setting case

# options            :
#                        blogname: 'blog title'
#                        blogdescription: 'blog description'
  • permalink_structure setting permalink structure

    • set the following three permalink structures
    • see Using Permalinks
    • structure set the permalink structure using the structure tags
    • category set the prefix of the category archive
    • tag set the prefix of the tag archive
  • import_xml_data local WordPress export (WXR) file path /vagrant/import/~.xml

    • Any one of three ways (import_xml_data, import_db_data or theme_unit_test) to import
  • import_db_data local sql dump file path /vagrant/import/~.sql
    • Any one of three ways (import_xml_data, import_db_data or theme_unit_test) to import
  • theme_unit_test import Theme Unit Test data enabled flag (default: false / value: true | false)
    • Any one of three ways (import_xml_data, import_db_data or theme_unit_test) to import
  • replace_old_url replace to vm_hostname from old url
  • regenerate_thumbnails regenerate thumbnails enabled flag (default: false / value: true | false)

Develop & Deploy Settings

  • WP_DEBUG debug mode (default: true / value: true | false)
  • SAVEQUERIES save the database queries (default: true / value: true | false)
  • php_version version of PHP (default: 7.0.7)
  • develop_tools activate develop tools (default: false / value: true | false)
  • deploy_tools activate deploy tools (default: false / value: true | false)

Directory Layout

Directory structure of VAW is as follows.

This directory synchronize to the guest OS side /vagrant. wordpress creates automatically and synchronize to vm_document_root.

uploads is the directory where stored images in wp-content directory of WordPress. uploads will be placed automatically in WordPress which was built at the time of provisioning, if you place uploads in this directory from the production environment.

You can create the same environment as the production environment, when you build a wordpress by import database dump data, substitution of url, regeneration of thumbnail image. You can set all from the provisioning configuration file.

Full Layout

  • backup (stores backup file. create automatically at running script, if it does not exist.)
  • command (stores shell script)
  • config (stores Custom Config)
  • config.sample (sample Custom Config)
  • group_vars (stores the provisioning configuration file of Ansible)
    • all.yml (provisioning configuration file)
  • hosts
    • local (inventory file)
  • import (stores import data)
  • plugins (stores WordPress plugin zip format files)
  • Rakefile (Rakefile of ServerSpec)
  • readme-ja.md
  • readme.md
  • roles (stores Ansible playbook of each role)
  • site.yml (Ansible playbook core file)
  • spec (stores ServerSpec spec file)
    • localhost
    • spec_helper.rb
  • themes (stores WordPress theme zip format files)
  • uploads (uploads directory in the wp-content)
  • Vagrantfile (Vagrant configuration file)
  • wordpress (synchronize to the Document Root. create automatically at vagrant up, if it does not exist.)

Minimum Layout

VAW will be built in the directory structure of the following minimum unit.

  • group_vars (stores the provisioning configuration file of Ansible)
    • all.yml (provisioning configuration file)
  • hosts
    • local (inventory file)
  • roles (stores Ansible playbook of each role)
  • site.yml (Ansible playbook core file)
  • Vagrantfile (Vagrant configuration file)
  • wordpress (synchronize to the Document Root. create automatically at vagrant up, if it does not exist.)

Vagrant Box

Vagrant Box is probably compatible with centos-7.x x86_64 and centos-6.x x86_64.

By default, the Vagrantfile uses the vaw/centos*-default Box which has already provisioned default settings.

In addition, can use the vaw/centos*-full Box which has already provisioned default settings and activate develop and deploy tools.

You can build the environment in a short period of time compared with provisioning from the pure vagrant Box.

CentOS 7

CentOS 6

Specification

Server (Selectable)

FastCGI (Selectable, Only nginx)

  • PHP-FPM (FastCGI Process Manager)
  • HHVM (HipHop Virtual Machine)

Database (Selectable)

Pre-installing

Develop Tools (Activatable)

Deploy Tools (Activatable)

Other

Helper command

  • after_provision.sh
  • before_provision.sh
  • db_backup.sh
  • phpenv.sh

Helper command

VAW offers a useful scripts. Just run the script on a terminal. Database data backup, multiple versions installation of PHP, you can switch the execution environment.

db_backup.sh

db_backup.sh will back up the database. Save at backup-%Y%m%d%H%M%S.sql format in the backup folder.

cd /var/www/html
/vagrant/command/db_backup.sh

phpenv.sh

phpenv.sh will prepare the specified version of PHP execution environment. You can install the specified version of PHP. Switching the PHP version. And then restart Apache or PHP-FPM by switching the server configuration environment.

/vagrant/command/phpenv.sh 7.0.7

Custom Config

When you add a tuning configuration file that you edited in the directory config, place it at the time of provisioning. As follows editable configuration files.

  • default-ruby-gems.j2
  • default-node-packages.j2
  • httpd.conf.centos6.j2
  • httpd.conf.centos7.j2
  • httpd.www.conf.centos7.j2
  • my.cnf.j2
  • nginx.conf.j2
  • nginx.multisite.conf.j2
  • nginx.wordpress.conf.j2
  • nginx.wordpress.multisite.conf.j2
  • php-build.default_configure_options.j2
  • php.conf.j2

Shortening of provisioning time by Vagrant plugin vagrant-cachier

When you install the Vagrant plugin vagrant-cachier, can shorten the provisioning time.

Installed package will be cached by the Box unit. When you launch multiple environments using the same Box, you can shorten the provisioning time using the cache.

How to delete cache

The cache is located in the host side, like this:

ls -al $HOME/.vagrant.d/cache/

Delete the cache, the following command by Box.

rm -rf $HOME/.vagrant.d/cache/vaw/centos7-default

or,

rm -rf $HOME/.vagrant.d/cache/vaw/centos7-full

The command notation of if you are using the other Box.

rm -rf $HOME/.vagrant.d/cache/<box-name>/<optional-bucket-name>

See vagrant-cachier Usage.

Contribute

Small patches and bug reports can be submitted a issue tracker in Github. Forking on Github is another good way. You can send a pull request.

If you would like to contribute, here are some notes and guidlines.

  • All development happens on the develop branch, so it is always the most up-to-date
  • The master branch only contains tagged releases
  • If you are going to be submitting a pull request, please submit your pull request to the develop branch
  • See about forking and pull requests

Changelog

  • version 0.4.2 - 2016.10.04
    • add develop-tools role, fix build environment
    • fix the inline script to get the major version number
    • fix sudo user
    • fix shebang
  • version 0.4.1 - 2016.09.10
    • fix inline shell in Vagrantfile
    • fix nodejs version
  • version 0.4.0 - 2016.08.22
    • bump up php 7.0.7
    • change to package module from yum module
    • change default box to CentOS 7 from CentOS 6
    • add synced_folder /vagrant
    • add vagrant-vbguest
    • change to yum_repository module from template module
    • fix home_dir path into playbooks
    • add phpenv-composer, remove composer role
    • fix phpenv role
    • add nodenv role, remove nodejs, npm
    • change provision to ansible_local from inline shell
    • remove RepoForge repository
    • add webgrind
    • add phpmd
    • add prestissimo
    • fix re2c via yum
    • fix tests
    • add gulp-cli and npm-check-updates, remove gulp
    • change to become, since sudo has been deprecated
    • fix phpenv.sh
  • version 0.3.3 - 2016.05.31
    • fix playbooks
    • remove compass gem
    • refactoring phpenv.sh
    • disable OPcache
  • version 0.3.2 - 2016.02.09
    • add custom config
    • remove server tuning
  • version 0.3.1 - 2016.01.18
    • fix yum releasever version
  • version 0.3.0 - 2015.12.21
    • fix Vagrantfile
    • fix wp-cli role, compatible with WordPress 4.4
    • improve hhvm role
    • improve command phpenv.sh
    • support CentOS 7 x86-64
  • version 0.2.1 - 2015.10.09
    • add stylestats
    • add plato
  • version 0.2.0 - 2015.08.31
    • fix Fabric
    • fix WordPress plugins
    • fix rbenv and hhvm, MariaDB roles
    • fix memory 1.5GB
    • remove php55 and php-fpm roles
    • add command phpenv.sh
    • add phpenv role, replaced from php
  • version 0.1.8 - 2015.08.04
    • fix WordPress plugins
    • add PHPUnit Selenium
  • version 0.1.7 - 2015.07.06
    • add public_network
  • version 0.1.6 - 2015.06.15
    • add vm_box_version
  • version 0.1.5 - 2015.06.04
    • add Fabric
    • add wrk
    • add command db_backup.sh
    • nginx tuning
  • version 0.1.4 - 2015.04.29
    • fix Ansible 1.9.x
  • version 0.1.3 - 2015.02.17
    • fix fastcgi_spec.rb
  • version 0.1.2 - 2015.01.31
    • change how to set the environment variables to .bash_profile
    • fix Vagrantfile
  • version 0.1.1 - 2015.01.14
    • change setting format
    • fix yum repository metadata
    • add WordPress options
    • add sass and compass gems
    • fix wp-cli role
  • version 0.1.0 - 2014.12.22
    • initial release

License

VAW is distributed under GPLv3.

Copyright (c) 2014-2016 thingsym