my question is basically two questions, but since they are closely related I thought that it makes sense to ask them en-bloque.
Case:
I am running a webapplication, which is distributed over multiple AWS EC2 instances behind a AWS Elastic Load Balancer
Intended goals:
a) When deploying new app code (php) it should be automatically distributed to all EC2 instances.
b) When new EC2 instances are added, they should automatically "bootstrap" with the latest appcode
My thoughts so far:
ad a)
phing (http://phing.info) is probably the answer for this part. i would probably add multiple targets for each EC2 instance and when running a deploy it would deploy to all machines. probably unfortunately not in parallel. but that might be even beneficial when scripting it in a way where the EC2 instance is "paused" in the load balancer, upgraded, "unpaused" again and on to the next instance.
ad b)
not sure how i would achieve that. in a conventional "hardware based setup" i probably had a "app code" volume on a network storage device and when adding a new server i'd simply attach that volume. when deploying new appcode i had just one deploy operation to this volume. so i need some "central storage" from where the newly bootstrapped machine/instance downloads it's appcode. i thought about git, but after all git is not a deploy tool and probably shouldn't be forced to be used as one.
I'd be happy to see your setups for such tasks and hear your hints and ideas for such a situation.
Thanks,
Joshua
This could be made using phing. However, I'm not sure why you want new instances to automatically retrieve the appcode? Do you get extra instance very often? And in order for a)
to deploy code to several instances, it would still need to know them?
This setup requires a master deploy server and uses a push strategy. The master server needs phing, any required phing packages, and optionally ssh keys for the EC2 instances.
Suggestion for a)
(This is just a general outline of the phing tasks required)
scp
tarball to all EC2 instances (to a deploy folder)rsh
unpack tarball on EC2 instancesrsh
update symbolic link on EC2 instances so webserver folder points at new deploy folderThe above could be called after you have made a new release.
Suggestion for b) This could be achieved by running the phing script every couple of hours, have it login to the EC2 instances and check for the appcode. If it doesn't find it, it will deploy the newest final release. This of course, requires the EC2 instances to be setup correctly in regard to webservers, config files, etc. (However, this could also be achieved by remote shell via phing).
I've previously used similar setups, but haven't tried it with services like EC2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With