Ansible playbook for configuring development and production servers with WordPress.
This playbook will install and configure MySQL, WordPress, Nginx, and PHP-FPM. Vagrant is used to provision development servers and this comes with a basic Vagrantfile for an easy setup.
Install vagrant-vbguest to always keep VirtualBox Guest Additions up-to-date (optional):
$ vagrant plugin install vagrant-vbguest
Add hostname to /etc/hosts
.
Run vagrant up
to create and provision virtual machine.
Create an inventory file and a group vars file, both named production
. See development files for details.
Provision Amazon EC2 instances with:
$ ansible-playbook site.yml --private-key <private_key.pem> -i production -u ubuntu
If you want to run specific tasks, add --tags <tag>
when running ansible-playbook
.
All Ansible configration is done in YAML.
The following must always be defined as group variables:
env
developmenthost
example.devsite_name
Example Sitewp_admin_email
admin@example.devwp_admin_password
passwordwp_db_password
passwordwp_root
/srv/example.com/wordpress
A database can be imported by specifying the dump path as wp_db_import
. Ansible will automatically replace site URL with hostname
and all user passwords to wp_admin_password
.
# group_vars/development
wp_db_import: database.sql.gz
Plugins can be installed automatically by defining wp_plugins
.
# group_vars/wordpress
wp_plugins:
- { name: akismet, version: 3.0.1 }
- { name: jetpack, version: 3.0.2 }
Delete all WordPress content (sample comments, posts etc.) with:
# group_vars/development
wp_delete_content: true
Important: Remember to remove the wp_delete_content
variable or set it to false
before provisioning the server again.
More role defaults can be found in roles/<role>/defaults/main.yml
and easily overwritten using group variables.
Enable virtual machine folder sync in your Vagrantfile.
# Vagrantfile
Vagrant.configure("2") do |config|
config.vm.synced_folder "../example-theme", "/srv/example.com/wordpress/wp-content/themes/example-theme", nfs: true
end
MIT © Richard Käll