Opsworks chef 12 recipes

Has anyone tried to convert Opsworks Chef v11 recipes to Chef v12?

I run several stacks on chef 11 and decided to start converting some of them to chef 12. Since AWS has lost its opsworks application levels, for example, the rails layer recipes, we (opsworks users) are now responsible for creating the deploy user, git checkout repos in deploy_to etc.

All this is good with flexibility and no namespace conflicts, but we are missing all that good opsworks stuff gave us for free.

I wonder if someone converted the recipes for chef 12 and open-sourced? Otherwise, the community is interested in these recipes? I'm sure Im not alone here.

Thank you in advance!

+5
source share
3 answers

The opsworks_ruby cookbook in the supermarket is basically all you need. It even puts applications in the same directories (i.e. /srv/www/app_name/ ), configures your database.yml, etc. Etc.

The main difference between this recipe and other non-OpsWorks recipes is that it will pull everything out of the OpsWorks configuration for you. You do not need to configure recipes, just make sure your application and layers are named correctly - it will build everything from there - including your RDS setup for database.yml!

The main difference is that the layers in OpsWorks will not be "Ruby aware", so you will not have fields for Rails-ish or Ruby-ish, and instead you will have to manage them elsewhere. The way to load ENV vars is a bit different.

Also be sure to read about implementing AWS Chef 12 for OpsWorks. They technically have two cookbooks, one internal and one yours. They include agent management, relevance, user load (for ssh), monitoring posting, etc. You will have to manage the rest.

We either replaced the material from our huge cookbook with individual cookbooks from the supermarket, or simply rewrote it. For example, the old chef 11 opsworks_initial_setup had several things related to setting network and linux settings - we recreated this.

It also uses deployment users, if applicable, for example:

$ ps -eo user,command USER COMMAND // snip root nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf aws opsworks-agent: master 10820 aws opsworks-agent: keep_alive of master 10820 aws opsworks-agent: statistics of master 10820 aws opsworks-agent: process_command of master 10820 deploy unicorn_rails master --env production --daemonize -c /srv/www/app/shared/config/unicorn.conf deploy unicorn_rails worker[0] --env production --daemonize -c /srv/www/app/shared/config/unicorn.conf deploy unicorn_rails worker[1] --env production --daemonize -c /srv/www/app/shared/config/unicorn.conf deploy unicorn_rails worker[2] --env production --daemonize -c /srv/www/app/shared/config/unicorn.conf deploy unicorn_rails worker[3] --env production --daemonize -c /srv/www/app/shared/config/unicorn.conf nginx nginx: worker process nginx nginx: worker process

Just a small example of the output of a process, but root loads things as needed, and each process uses its own users to restrict rights and access.

+3
source

I think the most common way is to use the β€œapplied” cookbook from the supermarket: https://supermarket.chef.io/cookbooks/application/versions/4.1.6 (which is also based on Equilibrium). Note: use version ~ 4 , they removed almost all the good features in version 5.

It will create a directory structure, support various deployment strategies, and offer some connectivity events. Keep in mind: in my opinion, the Opsworks documentation is very useful when it comes to the "deploy with opsworks and chef12" section: information from gui (for example, repo-url, etc.) is not on the node object, but in the database data from the application. For debugging, it can be very useful to look in the directory /var/chef/runs/<run-id>/ to find out what is available from here. A small snippet that shows the idea:

 app = search("aws_opsworks_app").first application "#{app['shortname']}" do owner 'root' group 'root' repository app['app_source']['url'] revision 'master' path "/srv/#{app['shortname']}" end 

This will create the release structure / current directory on /srv and check the code. Note: you might think that the ssh key that you specify in the GUI is somehow automatically placed in the right place. He is not, you have to take care of it yourself. Check out the chef11 opsworks cookbook: https://github.com/aws/opsworks-cookbooks/blob/release-chef-11.10/scm_helper/libraries/git.rb

+1
source

I don't know about the old OpsWorks cookbooks, but check out https://github.com/poise/application_examples/ for some examples of Rails (and more) deployments using a simple chef (will also work on OpsWorks).

0
source

Source: https://habr.com/ru/post/1246104/


All Articles