Created
May 13, 2019 13:34
-
-
Save hervekhg/6ee114e72a052e1e2a0aef88f15d051f to your computer and use it in GitHub Desktop.
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
# Install ansible | |
easy_install pip | |
# Instance name and ID | |
AWS_REGION="${region}" | |
INSTANCE_ID="$( curl http://169.254.169.254/1.0/meta-data/instance-id )" | |
#Download Ansible scripts | |
if [ ! -d "/home/ec2-user/${project_name}" ]; then | |
su - ec2-user -c "mkdir /home/ec2-user/${project_name}" | |
fi | |
su - ec2-user -c "aws s3 cp s3://bucket/ansible.tar.gz /tmp" | |
su - ec2-user -c "tar -xzf /tmp/${project_name}-ansible.tar.gz -C /home/ec2-user/${project_name}" | |
#Ansible installation | |
pip install ansible==$(cat /home/ec2-user/${project_name}/.ansible.version) | |
pip install python-consul | |
pip install boto3 | |
pip install awscli --upgrade | |
/usr/local/bin/ansible-playbook -v /home/ec2-user/${project_name}/main.yml -e env=\"${env}\" -e install=\"${install_name}\" -e project=\"${project_name}\" -e version=\"${version_lot}\"" | |
#Remove tmp files | |
su - ec2-user -c "rm /tmp/${project_name}-ansible.tar.gz" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment