I'm not a specialist in networking and I'm struggling at the moment trying to setup auto scaling for a web application.

I have one server - we can call it master - (outside the auto scaling group) which I use for memcache and beanstalkd queue. I also want to use this server to do a source code sync using rsync.

I want my server from the auto scaling group to be able to ssh this master server to perform an rsync and make sure the AMI has the latest version of the application.

I want to perform this sync when the scale-up alarm is triggered and a new instance is launched. I've read that I have to user --user-data-file to execute the script the first time the server is booted.

So this is all the information I have a the moment. I've setup my "launch config", "auto scaling group", "scale up" and "scale down" policy, and both alerts to trigger those policy.

I'm using a custom (private) AMI based on Centos 6 public AMI. When a new instance of the auto scaling group is launched, I have the impression that the bootstrap.sh script is not executed. Here is my launch config:

as-create-launch-config --image-id <PRIVATE_AMI> --instance-type m1.medium --key master --group webserver-security-group --user-data-file /home/user/bin/bootstrap.sh --launch-config my-lc-1

Here is the content of /home/user/bin/bootstrap.sh:

set -e -x

# Start the workers

So my first problem is that I have no idea why this script is not executed.

The second issue I have is that I'm not sure how to allow SSH connection to the "master" server knowing that the instance is changing when scaling up or down.

Help would be greatly appreciated ;)



So Centos AMI does not include CloudInit service by default (some of Ubuntu and Debian have it by default). You need to install it on your AMI, start the service on the boot:

chkconfig cloud-init on

Update the configuration file as needed: /etc/cloud/cloud.cfg Then you need to create a new AMI of the one modified. To test the bootstrap script the easiest I've found is to start a micro instance of this AMI specifying the --user-data-file option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.