Last active
July 14, 2017 18:12
-
-
Save ZeroDeth/794e8bed411625b774e0358dd8ad4874 to your computer and use it in GitHub Desktop.
Install terraform v0.9.5, packer v0.10.2, ansible v2.0.0.2, docker.io v1.12.6, awscli, ebcli and update ubuntu packages.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -x | |
TERRAFORM_VERSION="0.9.5" | |
PACKER_VERSION="0.10.2" | |
# create new ssh key | |
[[ ! -f /home/ubuntu/.ssh/hostykey ]] \ | |
&& mkdir -p /home/ubuntu/.ssh \ | |
&& ssh-keygen -f /home/ubuntu/.ssh/hostykey -N '' \ | |
&& chown -R ubuntu:ubuntu /home/ubuntu/.ssh | |
# install packages | |
apt-get update | |
apt-get -y install docker.io ansible unzip | |
# add docker privileges | |
usermod -G docker ubuntu | |
# install pip | |
pip install -U pip && pip3 install -U pip | |
if [[ $? == 127 ]]; then | |
wget -q https://bootstrap.pypa.io/get-pip.py | |
python get-pip.py | |
python3 get-pip.py | |
fi | |
# install awscli and ebcli | |
pip install -U awscli | |
pip install -U awsebcli | |
#terraform | |
T_VERSION=$(terraform -v | head -1 | cut -d ' ' -f 2 | tail -c +2) | |
T_RETVAL=${PIPESTATUS[0]} | |
[[ $T_VERSION != $TERRAFORM_VERSION ]] || [[ $T_RETVAL != 0 ]] \ | |
&& wget -q https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip \ | |
&& unzip -o terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/local/bin \ | |
&& rm terraform_${TERRAFORM_VERSION}_linux_amd64.zip | |
# packer | |
P_VERSION=$(packer -v) | |
P_RETVAL=$? | |
[[ $P_VERSION != $PACKER_VERSION ]] || [[ $P_RETVAL != 1 ]] \ | |
&& wget -q https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip \ | |
&& unzip -o packer_${PACKER_VERSION}_linux_amd64.zip -d /usr/local/bin \ | |
&& rm packer_${PACKER_VERSION}_linux_amd64.zip | |
# clean up | |
apt-get clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment