-
-
Save grenade/d92915ea93df6baf2aea 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
#! /bin/bash | |
# This Source Code Form is subject to the terms of the Mozilla Public | |
# License, v. 2.0. If a copy of the MPL was not distributed with this | |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
# usage: | |
# $ SANDBOX="/builds/aws_manager" ENV="bld" PLATFORM="win" ARCH="64" TARGET_HOST="$ENV-2008-ec2-golden" /builds/aws_manager/a0bab1937fbc8f06cfff/register.sh | |
echo "Attempting IP allocation and DNS mapping" | |
TARGET_IP=`python $SANDBOX/cloud-tools/scripts/free_ips.py -c $SANDBOX/cloud-tools/configs/$ENV-$PLATFORM$ARCH -r us-east-1 -n1` | |
if [[ $(host $TARGET_IP) == *"not found"* ]] | |
then | |
# map env to domain | |
case "$ENV" in | |
bld) | |
DOMAIN="build";; | |
try) | |
DOMAIN="try";; | |
tst) | |
DOMAIN="test";; | |
*) | |
echo $"Usage: ENV={bld|try|tst} $0" | |
exit 1;; | |
esac | |
# create a DNS entry | |
invtool A create --ip $TARGET_IP --fqdn $TARGET_HOST.$DOMAIN.releng.use1.mozilla.com --private --description "Golden image: $TARGET_HOST" | |
echo "DNS entry (A record) created: $TARGET_HOST.$DOMAIN.releng.use1.mozilla.com" | |
# create a DNS reverse-mapping (required for puppet certs to work properly) | |
invtool PTR create --ip $TARGET_IP --target $TARGET_HOST.$DOMAIN.releng.use1.mozilla.com --private --description "Golden image: $TARGET_HOST" | |
echo "DNS reverse-mapping (PTR) created: $TARGET_HOST.$DOMAIN.releng.use1.mozilla.com" | |
# create a CNAME | |
invtool CNAME create --fqdn $TARGET_HOST.$DOMAIN.mozilla.org --target $TARGET_HOST.$DOMAIN.releng.use1.mozilla.com --private --description "Releng convention" | |
echo "DNS alias (CNAME) created: $TARGET_HOST.$DOMAIN.mozilla.org -> $TARGET_HOST.$DOMAIN.releng.use1.mozilla.com" | |
# wait for DNS changes to be SVN up'd onto each DNS server | |
i=1 | |
while ! host $TARGET_HOST.$DOMAIN.mozilla.org; do | |
sleep 1m | |
let i++ | |
echo "Slept ${i} minutes" | |
done | |
echo "DNS propagated" | |
fi |
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 | |
# This Source Code Form is subject to the terms of the Mozilla Public | |
# License, v. 2.0. If a copy of the MPL was not distributed with this | |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
# usage: | |
# $ SANDBOX="/builds/aws_manager" ENV="bld" PLATFORM="win" ARCH="64" TARGET_HOST="$ENV-2008-ec2-golden" /builds/aws_manager/a0bab1937fbc8f06cfff/wrapper.sh > >(tee $SANDBOX/$TARGET_HOST.$(date '+%Y%m%d%H%M%S').stdout.log) 2> >(tee $SANDBOX/$TARGET_HOST.$(date '+%Y%m%d%H%M%S').stderr.log >&2) | |
set -e | |
set -o pipefail | |
LOCKFILE="$SANDBOX/$TARGET_HOST.lock" | |
lockfile -60 -r 3 "$LOCKFILE" | |
trap "rm -f $LOCKFILE" EXIT | |
cd $SANDBOX/cloud-tools/scripts | |
$SANDBOX/bin/python "aws_create_instance.py" -c $SANDBOX/cloud-tools/configs/$ENV-$PLATFORM$ARCH -r us-east-1 -s aws-releng -k $SANDBOX/secrets/aws-secrets.json --ssh-key ~/.ssh/aws-ssh-key -i $SANDBOX/cloud-tools/instance_data/us-east-1.instance_data_server_$PLATFORM$ARCH.json --create-ami --ignore-subnet-check --copy-to-region us-west-2 $TARGET_HOST | |
echo "Instance created: $TARGET_HOST" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment