An ansible role for Anchor CMS

What you can learn from this post

What we want to do

In broad strokes, this is what we want to do:

  1. Update your system apt-get update && apt-get upgrade

  2. Install the required packages apt-get install unzip vim apache2 libapache2-mod-php5 mysql-server php5-curl php5-mcrypt php5-gd php5-mysql

  3. Secure your mysql install

  4. Edit /root/.my.cnf in case you want to get into Mysql from the console without typing a password vim /root/.my.cnf

user = root
password = <YourPassword>
  1. Create the database To get in: mysql To create the database: mysql> create database anchor; quit

  2. Check your firewall to allow for ports SSH and HTTP outbound ufw status or iptables -nvL

  3. Get anchor cd /var/www/html; wget -O; unzip

  4. Adjust permissions chown -R www-data:www-data anchor-cms

  5. Setup apache to allow for .htaccess sed -i 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf

  6. Enable apache modules a2enmod rewrite

  7. Add the .htaccess to the base directory ( /var/www/html/anchor-cms/.htaccess )

Options -indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [L]

<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
  1. Restart services service apache2 restart; service mysql-server restart

  2. Go to http:/// (or http://localhost:8080 in case of Vagrant) to start the installation.

Now with Ansible

So I spent an afternoon and got it done using Ansible! This is version 1 so Iā€™m sure it can be vastly improved. Oh! And it has a Vagrantfile in case you want to try it out locally with vagrant up.

You can see the code here or the Galaxy role here!

There is one step that I could not automate because it has to be done after the configuration and installation process of Anchor itself which you can do manually:

rm -rf /var/www/html/anchor-cms/install