wordpress-ansible

This repository consists of all the required Ansible playbook and bash scripts needed for installing and configuring wordpress application on AWS Wordpress EC2 instance environment.

bash Scripts

Bash script plays a very cruscial role in setting up appropriate configuration for ansible to provision remote EC2 wordpress instance. replace.sh.param is redirected as replace.sh within bootstap section of AnisbleInstance EC2 in CloudFormation template. replace.sh is executed as root during bootstrap process of stack creation. replace.sh scripts performs following tasks.

  • Queries AWS for CloudFormtion stack output details.
  • Using output of above command and ###jq utility extracts the IP address of Ansible EC2 instance
  • Using sed, replaces MySql credential placeholders with values passed in CloudFormation template
  • Retrieves EC2 ssh2 key pair file from a dedicated S3 bucket
  • Generates ssh key pair for root user
  • Using ec2 ssh keypair and as a ubuntu user, SCP's root user's public ssh key to wordpress EC2
  • Using remote SSH session executes ssh_setup.sh. This scripts performs SSH setup for root user.
  • Launches playbook to configure wordpress in remote EC2 wordpress instance.

Ansible related playbook and configuration files

Ansible setup includes roles based configuration process where a playbook is devided in multiple parts based on role it plays. Within this set up we have following roles.

  • server
  • php
  • mysql
  • wordpress

server role

server role is used for installing following components

  • apache2
  • php-mysql
  • php
  • python3-pip
  • python3-mysqldb
  • libapache2-mod-php
  • Install MySQL database and configure root/admin password. This is passed as a parameter in CloudFormation temmplate

php role

php role installs following dependencies

  • php-gd
  • php-ssh2

mysql role

This role performs following tasks.
Values for below configuration is passed as parameter in CloudFormtion template.

  • Creates MySQL database
  • Creates user name for above database.
  • Creates password
  • Grants appropriate previliges

worpress

This roles performs following tasks

  • Dowloads wordpress tar ball from https://wordpress.org/latest.tar.gz and extracts to /var/www/
  • Configure wordpress application server with database details described in above sections