Sunday 15 August 2010

bash - Packer - Shell Script Provisioner to Clone Private Repo - Auto-Launch EC2 Instances -



bash - Packer - Shell Script Provisioner to Clone Private Repo - Auto-Launch EC2 Instances -

so i've looked around trying figure out way packer build download private repository ec2 ami build used spinning new instances under auto-launch configuration. having newly created ec2 instance, grab private repo.

it seems secure way grab private repo utilize deploy key, believe have manually add together each deploy key repo each instance...which defeats automation purpose, unless i'm doing wrong.

so essentially, i'm wondering how clone private repository through packer, through shell script or other wise. understand can utilize chef, don't think should have install dependency when thing i'm trying clone github repository.

do have write send/expect type of script uses https github clone url?

any , help appreciated.

there's "workaround" using ssh-agent. workaround because it's not particularly elegant. improve have part of puppet module (maybe there's 1 already).

the thought need generate pair of public/private key each of private github repository. add together public key deploy key in github project settings (settings/deploy keys). store key pair you.

now in packer, utilize shell provisioner , execute along these lines:

#!/usr/bin/env bash ssh-keyscan github.com >> /home/ec2-user/.ssh/known_hosts eval `ssh-agent` ssh-agent bash -c \ 'ssh-add /home/ec2-user/.ssh/[privatekey]; git clone git@github.com:[account]/project.git'

the advantage approach can clone multiple private repositories easily.

there few ways upload key pair on ec2 box, either using file provisioner , chef or puppet.

bash shell github amazon-ec2 packer

No comments:

Post a Comment