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 · 5 comments
Closed

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

spuder opened this issue May 23, 2015 · 5 comments

Comments

@spuder
Copy link
Contributor

spuder 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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor Author

spuder 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
Copy link
Contributor Author

spuder commented May 30, 2015

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

@spuder spuder closed this as completed May 30, 2015
@lock
Copy link

lock bot commented Apr 25, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants