Skip to content

Instantly share code, notes, and snippets.

@piroux
Last active June 8, 2018 23:51
Show Gist options
  • Save piroux/f68f7ab5d8b11ac4eea841f8e98f5e45 to your computer and use it in GitHub Desktop.
Save piroux/f68f7ab5d8b11ac4eea841f8e98f5e45 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euxo pipefail
# Requirements:
# - python 2.7
# - virtualenv
# - Docker > CE-17.03/EE-1.13
# - Git > v2
# Purge directory to start fresh
rm -rf deploy_project
mkdir deploy_project
cd deploy_project
# Pull the ansible branch
git clone --depth=1 https://github.com/ansible/ansible.git ansible_devel
pushd .
cd ansible_devel
#git checkout COMMIT_HERE .
#git checkout f04c876ecd .
popd
# Pull the awx branch
git clone https://github.com/ansible/awx.git awx_devel
pushd .
cd awx_devel
AWX_GIT_TAG=1.0.6
git checkout tags/${AWX_GIT_TAG} -b v${AWX_GIT_TAG}
popd
# Isolate this deployment project
virtualenv deploy_venv
set +e +u
source $(readlink -e deploy_venv/bin/activate)
set -e -u
# Install requirements & ansible & awx
pip install -U pip setuptools
pip install ndg-httpsclient
pip install ipython ipdb httpie requests[security]
pip install docker
pip install -e ./ansible_devel
pip install -e ./awx_devel
# Prevent to pull the Docker images from DockerHub in order to build them locally
# from the selected versions of ansible/awx during the previous `git checkout` commands
sed -i '/^dockerhub_base=ansible$/s/^/#/g' ./awx_devel/installer/inventory
sed -i '/^dockerhub_base=ansible$/s/^/#/g' ./awx_devel/installer/inventory
# Change the default admin credentials
sed -i 's/^# default_admin_user=.*/default_admin_user=chico/g' ./awx_devel/installer/inventory
sed -i 's/^# default_admin_password=.*/default_admin_password=loco/g' ./awx_devel/installer/inventory
# Change parameters for awx_web and postgres
sed -i 's|^postgres_data_dir=.*|postgres_data_dir=/tmp/pgdocker|g' ./awx_devel/installer/inventory
sed -i 's|^host_port=.*|host_port=12589|g' ./awx_devel/installer/inventory
# Clean the entire Docker runtime (be careful!)
# Remove -f to force asking for pruning
printf "Cleaning Docker\n"
docker system prune -a -f
printf "Purge the database volume directory\n"
rm -rf /tmp/pgdocker
mkdir /tmp/pgdocker
sync
# Finally deploy AWX
printf "Ready to Deploy AWX\n"
sleep 5
ansible-playbook -vvv -i ./awx_devel/installer/inventory ./awx_devel/installer/install.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment