Skip to content
This repository has been archived by the owner on Aug 27, 2020. It is now read-only.

Ansible playbook for configuring development and production servers with WordPress.

License

Notifications You must be signed in to change notification settings

richardkall/ansible-wordpress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ansible-wordpress

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.

Requirements

Usage

Development

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.

Production

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.

Config

All Ansible configration is done in YAML.

The following must always be defined as group variables:

  • env development
  • host example.dev
  • site_name Example Site
  • wp_admin_email admin@example.dev
  • wp_admin_password password
  • wp_db_password password
  • wp_root /srv/example.com/wordpress

Import database

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

WordPress Plugins

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 sample content

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.

Synced folders

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

License

MIT © Richard Käll

About

Ansible playbook for configuring development and production servers with WordPress.

Resources

License

Stars

Watchers

Forks

Languages