Skip to content

Instantly share code, notes, and snippets.

@moondev
Last active August 2, 2016 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moondev/5ea8fa608d1cd1d0006d4962061a4b66 to your computer and use it in GitHub Desktop.
Save moondev/5ea8fa608d1cd1d0006d4962061a4b66 to your computer and use it in GitHub Desktop.
Packer wrapper for spinnaker rosco multi region baking
#!/usr/bin/env bash
#This shell script goes in /usr/local/bin/packer
#
#The real packer binary is at /opt/packer
#
#The script looks for region in the params and then adds that to the end of aws-ebs.json and calls it with the real packer /opt/packer
#
#So Rosco goes:
#
#packer build -color=false -var aws_region=us-west-2 -var aws_ssh_username=ubuntu -var aws_instance_type=t2.micro -var aws_source_ami=ami-d732f0b7 -var aws_target_ami=nginx-all-20160721161956-ubuntu -var aws_associate_public_ip_address=true -var package_type=deb -var packages=nginx -var configDir=/opt/rosco/config/packer /opt/rosco/config/packer/aws-ebs.json
#
#Fake packer intercepts it because it is on the PATH and then calls:
#
#/opt/packer build -color=false -var aws_region=us-west-2 -var aws_ssh_username=ubuntu -var aws_instance_type=t2.micro -var aws_source_ami=ami-d732f0b7 -var aws_target_ami=nginx-all-20160721161956-ubuntu -var aws_associate_public_ip_address=true -var package_type=deb -var packages=nginx -var configDir=/opt/rosco/config/packer /opt/rosco/config/packer/aws-ebs-west-2.json
#
#aws-ebs-west-2.json and aws-ebs-east-1.json have their specific vpc and subnet info.
ARGS="$@"
REGION=$4
IFS='=' read -ra REG <<< "$REGION"
NEWCONFIG="aws-ebs-${REG[1]}.json"
OLDCMD="$ARGS"
ARGS="${OLDCMD/aws-ebs.json/$NEWCONFIG}"
/opt/packer $ARGS
@medyagh
Copy link

medyagh commented Aug 2, 2016

does this work even find image look up on pipelines ? if I have a pipeline and say find image in another pipeline ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment