Created
September 5, 2019 19:06
-
-
Save NZSmartie/33ecd7ba811ccf97f6dc854bdd946c53 to your computer and use it in GitHub Desktop.
ec2 inventory bootstrap for ansbile
This file contains hidden or 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 -e | |
# Discover the current version of ansible | |
ANSILBE_VERSION=$(ansible --version | sed -rn 's/.*ansible ([0-9.]+).*/\1/p') | |
# If 'region = auto' is set in ec2.ini, then we need to export the region from the local aws configutation | |
export AWS_DEFAULT_REGION=$(aws configure get region) | |
# Download the ec2.py script that matches the ansible version | |
curl -Ss "https://raw.githubusercontent.com/ansible/ansible/v${ANSILBE_VERSION}/contrib/inventory/ec2.py" -o ec2.py | |
chmod a+x ec2.py | |
./ec2.py $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment