ruby - automated deployments using chef -
i running ruby on rails e-commerce application running on couple of ec2 instances in production. have not enabled auto scaling since continuous integration, deployment when ever required. using chef reasons. trying figure out how use chef deploy code multiple ec2 instances automcatically , manual intervention. tried deploy code during initial ec2 instance works fine. question how do in auto scaling mode instance pull latest code either github or bit bucket , deployes itseld after bundle updating , all.
fair enough. , works fine:
i have created ami below settings:
install chef client
create
/etc/chef
directory- copy
your_company-validator.pem
chef workstation ami @/etc/chef/validation.pem
- create
/etc/chef/client.rb
below.
if use chef-solo, make changes accordingly.
cat >> /etc/chef/client.rb <ef log_level :auto log_location stdout chef_server_url "https://api.opscode.com/organizations/your_company" validation_client_name "you_company-validator" ef
now, have above stuff configured in ami chef bootstrap.
when launch ami (using autoscaling or other way), provide user-data
in run chef-client run_list of choice. provide below user-data:
#!/bin/bash cat > /etc/chef/firstboot.json << eol {"run_list": ["recipe[java::oracle]"]} eol chef-client -j /etc/chef/firstboot.json > /tmp/initialize_client.log 2>&1
basically, creating .json file specify recipe/role/run_list want run. once provide user-data, executed on 1st boot , chef-client run along run_list.
i think looking for. summarize:
- create ami pre-installed
chef-client, client.rb , validation.pem
- and provide
user-data
@ time of instance launch.
this works me. let me know if set-up gives trouble. have been using quite time.
so when launch instance using autscaling, gets automatically chef-bootstrapped along recipes of choice.
assumption: have recipes/roles created on chef-server before doing this. else bootstrap fail.
Comments
Post a Comment