In The Beginning…

 
I’ve been running a number of WordPress sites at AWS, and using the Bitnami AMIs to do so.  They make it super easy, just fire up an instance of the AMI, and boom you have a full WordPress environment up and running, with Apache, WordPress, and a database.

When The Palace Becomes a Prison

 
While everything worked okay at first, over time I’ve grown less and less happy with this setup.
 
The installation location for all the software components, htdocs directory, database, etc.. are all different from what you’d expect from running a typical Linux server running those applications.  The control scripts are completely different, and I often had to read the online manuals to figure out how to do something basic.
You also don’t have any good upgrade path.  You can upgrade WordPress itself in-place using the WordPress admin.  However if you want to upgrade the stack (Apache, PHP, MySQL, etc…) you are out of luck, because they aren’t installed or managed by the package manager.  Bitnami’s advice is to spin up a new EC2 instance, using the new AMI, and then port your whole site, static content, any additional pages, configurations, etc… over, update DNS, terminate the old EC2 instance, and then you’ve “upgraded”.
So a few weeks ago I decided that I wanted to move off of Bitnami entirely.  I also wanted to homogenize my EC2 instances’ Linux variants, so I wasn’t switching between yum and apt servers all the time, and I wanted to standardize my user account, ssh keys, etc…
But I also didn’t want to be manually installing WordPress stacks on servers over and over, both immediately for the migration, but also in the future, as I know I will be adding more and more sites to my stable.  So

Enter Automation Through Ansible

 
I setup Ansible playbooks to do things like setup my user account, ssh keys, sudoer rules, and install common utilities I always want available.  I then created roles for installing apache, mariadb, php, and other applications, and then a WordPress role that customizes everything to provide a running WordPress environment, including installing any plugins or themes I want, just like Bitnami does, except all in the standard locations, using the standard package manager, and fully upgradable in-place.  I also built out roles for servers to run Java applications, and other common (for me) uses.

In The End…

 
So far this system has been great!  It didn’t take long to setup, even though I am FAR from an Ansible expert.  It’s been working great, and as I make improvements, tune MariaDB, etc.. those changes can be quickly pushed out to my entire environment of servers.  New servers are a breeze to setup, with WordPress being ready for a new site or a site import in just a few minutes.
If there is interest I may make my Ansible setup public (I didn’t write it to be public so there’s few comments, and some personal keys/names I’d need to strip out first).  So if you’re interested, let me know!  [email protected]