Cloud-init script for AWS installation (CentOS 7, Docker local)

,

I just thought I’d share this, since it’s super handy for throwing an AWX host up on a CentOS 7 host on AWS…following the local Docker method with AWX logos. This script can be copied/pasted into “User data” under 3.Configure Instance Details → expand Advanced in the EC2 Launch Instance wizard.

#!/bin/bash

yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm --enablerepo=extras

yum install -y ansible vim docker git make python-pip lvm2 --enablerepo=extras

yum update -y

pip install docker-py

pvcreate /dev/xvdf

vgcreate vg_awx /dev/xvdf

lvcreate -l 100%FREE vg_awx -n lv_awx

mkfs.ext4 /dev/vg_awx/lv_awx

mkdir /awx

mount /dev/vg_awx/lv_awx /awx

echo ‘/dev/vg_awx/lv_awx /awx ext4 defaults 0 2’ >> /etc/fstab

systemctl start docker

systemctl enable docker

cd /awx

git clone https://github.com/ansible/awx.git

git clone https://github.com/ansible/awx-logos.git

cd awx/installer

sed -i ‘s/awx_official=false/awx_official=true/’ inventory

ansible-playbook -i inventory install.yml

docker logs -f awx_task

Note: I might have missed something, because I can access the AWX web control panel through http, but not https…I’m not sure why yet, as I am new to Docker and AWX.

I forgot to mention:
While provisioning the instance, you will need to create a second volume for sdb…I used 12-20 GB, which worked fine to start playing with.
You will need to set up Security Group rules that allow you to access the http/https on your instance, and ssh if you want to log in and tail logs.
You can watch the install process with tail -f /var/log/cloud-init-output.log