Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question - How to do different configs on different servers #177

Closed
spuder opened this Issue May 23, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@spuder
Copy link
Contributor

commented May 23, 2015

I'm trying to figure out how to use this cookbook to deploy different configs on different servers.

I have

consul-server01
consul-server02
consul-server03
web01
database01

How can I make it so that the web servers and the database servers have different configs?

I'm thinking I could do one of the following. None of which seems optimal.

  1. Create wrapper cookbooks for each server type, the cookbook manages /etc/consul.d/web.conf ect..
  2. Create single cookbook with conditional statements that deploy different templates based on hostnames.

Is there something that I am missing? Whats the best way to deploy different configs to different servers?

@johnbellone

This comment has been minimized.

Copy link
Contributor

commented May 24, 2015

This may be easier with the develop branch. I am writing tests for it now
and hoping to have it ready to ship in a week or so.

You would use the new LWRP for different consul instances.
On Sat, May 23, 2015 at 12:02 Spencer Owen notifications@github.com wrote:

I'm trying to figure out how to use this cookbook to deploy different
configs on different servers.

I have

consul-server01
consul-server02
consul-server03
web01
database01

How can I make it so that the web servers and the database servers have
different configs?

I'm thinking I could do one of the following. None of which seems optimal.

  1. Create wrapper cookbooks for each server type, the cookbook manages
    /etc/consul.d/web.conf ect..
  2. Create single cookbook with conditional statements that deploy
    different templates based on hostnames.

Is there something that I am missing? Whats the best way to deploy
different configs to different servers?


Reply to this email directly or view it on GitHub
#177.

@tgwizard

This comment has been minimized.

Copy link
Contributor

commented May 24, 2015

One simple way would be to create three chef roles: consul-server, web, and database. Each of these include a their own recipe in their runlist, e.g. consul_server.rb, web.rb, and database.rb. These recipes could be in separate cookbooks, or in one common cookbook, depending on your use-case. The recipes depend on the consul cookbook and uses its resources/providers/LWRP to define services and checks.

Then either your roles also includes the consul cookbook directly, or your recipes does. We have a separate consul-agent role with its own attributes (specifying consul version, user to run as, which datacenter to run in, and extra common configuration). All roles that use consul also include the consul-agent role.

@spuder

This comment has been minimized.

Copy link
Contributor Author

commented May 26, 2015

Good idea,

Can a runlist include just a single recipe?

If so, I could make a consul-agent cookbook, where the default recipe is blank.

consul-agent::default   #blank
consul-agent::webserver
consul-agent::database

Then I just include the specific recipies in the role.

{
  "run_list": [
    "recipe[mywebserver]",
    "recipe[consul-agent::webserver]",
    "role[mywebserver]"
  ]
}
@spuder

This comment has been minimized.

Copy link
Contributor Author

commented May 30, 2015

^ This is what I ended up doing. It works well enough.

@spuder spuder closed this May 30, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.