Skip to content
VAW (Vagrant Ansible WordPress) is Ansible playbooks for website developer, designer, webmaster and WordPress theme/plugin developer.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
command
config.sample.tuning
config
group_vars
hosts
roles
spec
.editorconfig
.gitignore
.travis.yml
CHANGELOG.md
LICENSE
README-ja.md
README.md
Rakefile
Vagrantfile
site.yml

README.md

VAW (Vagrant Ansible WordPress)

The VAW (Vagrant Ansible WordPress) is Ansible playbooks for website developer, designer, 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.

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

VAW (Vagrant Ansible WordPress) documentation: https://thingsym.github.io/vaw/

Features

1. Build Server and Database environment

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

On all web servers, FastCGI configuration is possible. Build 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

The 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. The 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 4 ways
    • WordPress export (WXR) file
    • SQL file (database dump data)
    • Backup plugin "BackWPup" archive file (Zip, Tar, Tar GZip, Tar BZip2)
    • Theme Unit Test
  • Automatically place wp-content directory
  • Automatically place 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

Vagrant plugin (optional)

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-vbguest
vagrant plugin install vagrant-serverspec

4. Download Ansible playbooks of the 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 development 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 USER root
  • 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 configuration files of the VAW.

There are two configuration files you can customize.

  • Vagrantfile
  • group_vars/all.yml

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

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 and vm_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                = 'centos/7'
vm_box_version        = '>= 0'
vm_ip                 = '192.168.46.49'
vm_hostname           = 'vaw.local'
vm_document_root      = '/var/www/html'

public_ip             = ''

forwarded_port        = [ 3000, 3001 ]

vbguest_auto_update   = true
synced_folder_type    = 'virtualbox' # virtualbox|nfs|rsync|smb

ansible_install_mode  = :default    # :default|:pip
ansible_version       = 'latest'    # only :pip required

provision_mode        = 'all'       # all|wordpress|box
  • vm_box (required) name of Vagrant Box (default: centos/7)
  • 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: '')
  • forwarded_port list of ports that you want to transfer (default: [ 3000, 3001 ])
  • vbguest_auto_update whether to update VirtualBox Guest Additions (default: true / value: true | false) トします (default: true / value: true | false)
  • synced_folder_type the type of synced folder (default: virtualbox / value: virtualbox | nfs | rsync | smb)
  • ansible_install_mode (required) the way to install Ansible (default: :default / value: :default | :pip)
  • ansible_version version of Ansible to install (default: latest)
  • provision_mode (required) Provisioning mode (default: all / value: all | wordpress | box)

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|h2o
fastcgi            : none     # none|php-fpm

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

db_host            : localhost
db_name            : wordpress
db_user            : admin
db_password        : admin
db_prefix          : wp_
db_charset         : ''
db_collate         : '' # utf8mb4_general_ci

## WordPress Settings ##

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

# e.g. latest, nightly, 4.1, 4.1-beta1
# see Release Archive - https://wordpress.org/download/release-archive/
# 3.7 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

# default theme|slug|url|zip (local path, /vagrant/themes/*.zip)
activate_theme     : ''
themes             : []

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

theme_mod          : {}

# see Option Reference - http://codex.wordpress.org/Option_Reference
options            : {}

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

# Any one of 4 ways to import
import_xml_data    : ''   # local path, /vagrant/import/*.xml
import_db_data     : ''   # local path, /vagrant/import/*.sql
import_backwpup    :
                      path          : ''   # local path, /vagrant/import/*.zip
                      db_data_file  : ''
                      xml_data_file : ''
import_admin       : false   # true|false
theme_unit_test    : false   # true|false

replace_old_url         : [] # http(s)://example.com, to vm_hostname from old url
search_replace_strings  : {}
regenerate_thumbnails   : false   # true|false

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

## Develop & Deploy Settings ##

ssl                : true   # true|false

# See Supported Versions http://php.net/supported-versions.php
php_version        : 7.2.1
http_protocol      : https   # http|https

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

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

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

Server & Database Settings

  • server (required) name of web server (default: apache / value: apache | nginx | h2o)
  • fastcgi name of fastCGI (default: none / value: none | php-fpm)
  • database (required) name of databese (default: mariadb / value: mariadb | mysql | 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_)
  • db_charset database character set (default: '')
  • db_collate database collation (default: '')

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.7 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)

  • 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

Configuration example

themes             :
                     - yoko
                     - Responsive

Disable the setting case

themes             : []
  • 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

Configuration example

activate_plugins   :
                        - theme-check
                        - plugin-check

Disable the setting case

activate_plugins   : []
  • 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
  • theme_mod setting theme_mod (theme modification value)

Configuration example

theme_mod          :
                       background_color: 'cccccc'

Disable the setting case

theme_mod          : {}

Configuration example

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

Disable the setting case

options            : {}
  • 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
  • import_db_data local sql dump file path /vagrant/import/*.sql
  • import_backwpup
    • path Archive file path /vagrant/import/*.zip (Zip, Tar, Tar GZip, Tar BZip2)
    • db_data_file DB backup file name (Import from one of data files)
    • xml_data_file XML export file name (imported from one of the data files)
  • import_admin Add WordPress administrator user (default: false / value: true | false)
  • theme_unit_test import Theme Unit Test data enabled flag (default: false / value: true | false)
  • replace_old_url replace to vm_hostname from old url

Configuration example

replace_old_url         :
                           - http://example.com
                           - http://www.example.com
                           - https://example.com

Disable the setting case

replace_old_url         : []
  • search_replace_strings Search the database and replace the matched string

Configuration example

search_replace_strings  :
                           'foo': 'bar'
                           'abc': 'xyz'
                           'Hello, World!': 'Welcome to WordPress!'

Disable the setting case

search_replace_strings  : {}
  • regenerate_thumbnails regenerate thumbnails enabled flag (default: false / value: true | false)
  • WP_DEBUG debug mode (default: true / value: true | false)
  • SAVEQUERIES save the database queries (default: true / value: true | false)

Develop & Deploy Settings

  • ssl WordPress administration over SSL enabled flag (default: true / value: true | false)
  • php_version version of PHP (default: 7.2.1)
  • http_protocol HTTP protocol (default: https / value: http | https)
  • 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 the VAW is as follows.

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

wp-content is a directory that stores WordPress themes, plugins, and upload files. wp-content will be placed automatically in WordPress which was built at the time of provisioning, if you place wp-content in this directory from the production environment.

uploads is a directory where stored upload files 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, if necessary)
  • LICENSE (license file)
  • plugins (stores WordPress plugin zip format files, if necessary)
  • 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)
    • box
    • localhost
    • spec_helper.rb
    • sync-dir
  • themes (stores WordPress theme zip format files, if necessary)
  • 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.)
  • wp-content (WordPress's wp-content directory)

Minimum Layout

The 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

The VAW supports VirtualBox for providers of Vagrant. Operating system and architecture supported centos-7.x x86_64 and centos-6.x x86_64 Vagrant Box. To download Vagrant Box, you can search from Discover Vagrant Boxes.

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

In addition, you 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

Provisioning mode

The VAW has three provisioning modes.

  • all will normal provisioning from the pure Vagrant Box.
  • wordpress provisions only sync folders including WordPress.
  • box provision to create a Vagrant Box.

The VAW is characterized by being able to provision with various server and database configuration combinations. On the other hand, it takes time to build the environment from pure Vagrant Box.

You can create a Vagrant Box with server and database configuration in advance. By using the created Vagrant Box you can shorten the provisioning time.

First, create a Vagrant Box with Provision mode box. Next, provision the created Vagrant Box with Provision mode wordpress. Based on the Vagrant Box you created, WordPress development environment will start quickly anytime.

How to make Vagrant Box

How to use the provisioning mode?

Let's see how to make Vagrant Box through the process from provisioning with Vagrant Box to building WordPress development environment.

1. Setting of configuration file

We will launch the Vagrant environment for creating Vagrant Box. First of all, Set up the Vagrant configuration file and the provisioning configuration file.

Set provision_mode in the Vagrant configuration file to box.

provision_mode        = 'box'    # all|wordpress|box

You can set the provisioning configuration file as you like.

However, if provision_mode is box, the WordPress Settings section of the provisioning configuration file will be skipped during provisioning.

2. Provisioning

Provision and build the environment.

vagrant up

3. Creating a Vagrant Box (Packaging)

After provisioning is completed, create a Vagrant Box with a box name. (e.g. sample.box)

vagrant package --output sample.box

4. Registration of Vagrant Box

Add the created Vagrant Box to Vagrant. (Register as eg sample)

vagrant box add sample.box --name sample

You can delete the Vagrant Box file created for creating Vagrant Box. (e.g. sample.box) You can destroy the launched Vagrant environment after checking the operation.

vagrant destroy

5. Provisioning with the created Vagrant Box

Launch the Vagrant environment for WordPress development with the Vagrant Box you created. Set up the Vagrant configuration file and the provisioning configuration file.

Set vm_box of the Vagrant configuration file to sample. (e.g. sample) Set provision_mode in the Vagrant configuration file to wordpress.

vm_box                = 'sample'
...
provision_mode        = 'wordpress'    # all|wordpress|box

You can set the provisioning configuration file as you like.

However, if provision_mode is wordpress, only the WordPress Settings section of the provisioning configuration file is enabled during provisioning.

6. Launch a virtual environment

vagrant up

After provisioning, you can launch a WordPress development environment.

Specification

Server (Selectable)

FastCGI (Selectable)

  • PHP-FPM (FastCGI Process Manager)

Database (Selectable)

Pre-installing

Develop Tools (Activatable)

Deploy Tools (Activatable)

Other

Helper command

  • after_provision.sh
  • before_provision.sh
  • centos-box.sh
  • db_backup.sh
  • phpenv.sh

Helper command

The 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 -v 7.2.1 -m php-fpm -s unix

# help
/vagrant/command/phpenv.sh -h

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-node-packages.j2
  • default-ruby-gems.j2
  • h2o.conf.j2
  • httpd.conf.centos6.j2
  • httpd.conf.centos7.j2
  • httpd.www.conf.centos7.j2
  • mariadb.my.cnf.j2
  • mysql.my.cnf.j2
  • nginx.conf.j2
  • nginx.multisite.conf.j2
  • nginx.wordpress.conf.j2
  • nginx.wordpress.multisite.conf.j2
  • percona.my.cnf.j2
  • php-build.default_configure_options.j2
  • ssh-config.j2

Contribution

Patches and Bug Fixes

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.

  1. Fork VAW from GitHub repository
  2. Create a feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Create new Pull Request

Changelog

See CHANGELOG.md

License

The VAW is distributed under GPLv3.

Author

thingsym

Copyright (c) 2014-2018 thingsym

You can’t perform that action at this time.