0

I am new to chef (using hosted chef server) and am muddling along ok and basically understand how to provision individual servers. What I am having trouble with is figuring out how to integrate the various provisioned servers into a functional cluster.

In my current use case I am using Amazon EC2. I am using a load balancer with a few varnish servers which pass requests to several front end application servers connected to an RDS server. I also have a backend utility server which has to occasionally sync some files to the FE app servers.

How would you glue all of this together? The FE servers need to know about the rds instance and a redis server but the backend utlity server and the varnish nodes have to know about the FE app servers. Ideally the app servers will implement some kind of autoscaling where more nodes are provisioned as necessary.

Finally, couple this with also needing to have dev and stage environments as well where often the varnish servers are on the same VM as the app server.

Do you use tagging to sort of register the FE nodes and then query those values when you run recipes on the varnish and BE servers last?

I am just looking for some best practices on what I would assume is a fairly common n-tier web cluster use case.

runamok
  • 163
  • 10

1 Answers1

2

Your question doesn't specify whether you are using chef-client or chef-solo, so I will assume the former.

Two Chef constructs are particularly relevant to your question: search and environments.

Because the Chef server is indexing all the known attributes of your nodes, you can use search to locate nodes based on any attribute, e.g. the contents of their run lists or any tags you have assigned to the node. Assuming you have a recipe (or role) which sets up your redis server, a recipe which configures the FE app servers you described could search for nodes which have the redis recipe in their run list and use the attributes of that node to populate the app's config file. Similarly, a recipe which configures your Varnish servers could search out your app servers and populate the Varnish config file with their addresses.

Environments can be thought of as a special kind of tag, one that can be used to limit the scope of your search queries when you only want to know about nodes which belong to the same logical set. Beyond acting as a tag, Chef environments can also be used to override node attributes and enforce cookbook version locking.

Neither of these constructs is directly applicable to discovering parts of your infrastructure like RDS where you cannot directly run Chef, but because you can use "raw" ruby in your recipes, libraries like fog or right_aws will allow you to query the AWS API for details of resources you've provisioned, (e.g. which RDS instances exist and what their addresses are,) and you can filter the results using any tags you've applied.

By combining a library like fog with Chef's search capability, you should be able to search your way to cloud integration automation nirvana. Until the next major US-East outage.

cwjohnston
  • 556
  • 1
  • 4
  • 8
  • Thanks very much for your answer. You are correct that I am using chef-client (which I thought would be indicated by the fact that I am using hosted chef server). Would you know of any cookbooks, blog posts, etc. that give some examples of what I am trying to do? My boss pointed me to how the nagios client works with nagios server so that may be a good start. – runamok Jan 07 '13 at 18:47