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: Configuring Consul #229

Closed
majormoses opened this issue Oct 8, 2015 · 4 comments
Closed

Question: Configuring Consul #229

majormoses opened this issue Oct 8, 2015 · 4 comments

Comments

@majormoses
Copy link

From my understanding (I could be very wrong) of having read this cookbooks recipes and resource providers it looks to me like any value that is namespaced under node['consul']['config'](as long as the provider supports it) are passed to the consul_config and consul_service provider:

https://github.com/johnbellone/consul-cookbook/blob/master/recipes/default.rb#L38-L46

I have injected a bunch of config under and it does not seem to be having any affect. Here is the chef attributes I am passing it:

chef (12.4.3)> node.consul.config
 => {"datacenter"=>"dev", "advertise_addr"=>"10.40.22.237", "client_addr"=>"0.0.0.0", "enable_debug"=>false, "log_level"=>"INFO", "node_name"=>"ip-10-40-22-237.ec2.internal", "ui_dir"=>"/srv/consul-ui/current/dist", "recursors"=>["10.40.0.2"]}

Here is the consul config that is being generated:

{
  "data_dir": "/var/lib/consul",
  "server": true,
  "bootstrap": true,
  "ports": {
    "dns": 8600,
    "http": 8500,
    "rpc": 8400,
    "serf_lan": 8301,
    "serf_wan": 8302,
    "server": 8300
  }
}
@scalp42
Copy link
Contributor

scalp42 commented Oct 8, 2015

@majormoses this is how I go about it:

file node['gz-consul']['config_path'] do
  owner node['consul']['service_user']
  group node['consul']['service_group']
  mode '644'
  content lazy { JSON.pretty_generate(node['gz-consul']['config'], quirks_mode: true) }
  action node['gz-consul']['nuke'] ? :delete : :create
end

consul_service node['consul']['service_name'] do |r|
  data_dir node['gz-consul']['config']['data_dir']
  user node['consul']['service_user']
  group node['consul']['service_group']
  version node['consul']['version']
  config_file node['gz-consul']['config_path']
  node['consul']['service'].each_pair { |k, v| r.send(k, v) }
  if node['gz-consul']['nuke'] || node['is_packer']
    action [:disable]
  else
    subscribes :restart, %|file[#{node['gz-consul']['config_path']}|, :delayed unless service_status.any? { |x| [:disable].include?(x) }
    action service_status
  end
  ignore_failure true if node['gz-consul']['nuke']
end

Pretty much I generate the JSON myself and pass it to the consul_service resource.

Hopefully helps!

@majormoses
Copy link
Author

@scalp42 thanks let me take a crack at it.

@majormoses
Copy link
Author

@scalp42 thanks with a bit of modification that got me what I needed. Still having issues but I will try to see what is going on and open new issues accordingly.

@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

2 participants