This is a set of code that is from the Digital Ocean 'WordPress using Ansible' tutorial.
It has been upgraded to work on Ubuntu 16.04 rather than 14.04 as in the tutorial.
Other ansible installs that I found when searching just had too much in them that I didn't want. This has the minimum to get WordPress working, then you can just fork it and customise it.
This is designed to run on localhost only, but you can modify it for specific servers.
This installs:
- Ubuntu 16.04 LTS
- Apache (libapache2-mod-php)
- MySQL
- PHP 7 (php, php-mysql, php-mcrypt, php-gd, libssh2-php)
- Python-MySQL (for automated installation of MySQL DB)
- WordPress (latest)
- Ansible v2.6.0
- VirtualBox v5.2.14 (this could be any of the VMs that Vagrant supports)
- Vagrant v2.0.2
$ git clone https://github.com/BlankSlateCode/wordpress-ansible-vagrant.git
$ cd wordpress-ansible-vagrant
$ cp provisioning/roles/mysql/defaults/main-example.yml provisioning/roles/mysql/defaults/main.yml
$ cp provisioning/roles/server/defaults/main-example.yml provisioning/roles/server/defaults/main.ymlEdit provisioning/roles/mysql/defaults/main.yml and set the values:
wp_mysql_db: my_database
wp_mysql_user: my_user
wp_mysql_password: my_passwordEdit provisioning/roles/mysql/server/main.yml and set the values:
root_mysql_password: my_password$ vagrant up --provider virtualboxOnce the vagrant is running you can go to http://localhost:8080 - which should show a WordPress installation page.
This project comes from a tutorial that is purely Ansible based with no requirement for Vagrant. So the playbook is still perfectly runnable on it's own.
So the installation is exactly as the Vagrant installation except for the final command:
$ cd provisioning
$ ansible-playbook playbook.yml -i my-inventory.txtThis will run the playbook on localhost. You can change my-inventory.txt to be what ever server you want to run the Ansible playbook against.
The hope is that you can understand all the code that is here - at least by following the tutorial. There really isn't much and it could be all in one playbook.yml file. All the code bloat comes from the following commands (which create all the subdirectories under roles):
$ ansible-galaxy init server
$ ansible-galaxy init php
$ ansible-galaxy init mysql
$ ansible-galaxy init wordpress
I made a few modifications to the Digital Ocean tutorial:
- I include Vagrant in this as well, Vagrant and Ansible work very will together, but I believe that you can just use this code to run the playbook on its own - see the section on 'No Vagrant' above.
- Effectively I rely on
vagrant upto 'provision' the server which runs the ansible playbook. - If you modify the playbook after running vagrant up for the first time you have to run
vagrant provisionto force the re-run of the playbook - I am just using this for localhost development - so there is no
hostsfile and theplaybook.ymlfile useshosts: allwhich defaults to just localhost. The Digital Ocean tutorial has instructions for using other hosts. - I have upgraded it to Ubuntu 16.04.
This ansible playbook is fairly OS agnostic I think - so it should run on most Linux OSes.
This is very little beyond a simple LAMP setup. You can delete the wordpress role and remove it from playbook.yml then you have a LAMP system that will create you a MySQL database.