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

majormoses opened this Issue Oct 8, 2015 · 3 comments


None yet
2 participants
Copy link

majormoses commented Oct 8, 2015

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:

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"=>"", "client_addr"=>"", "enable_debug"=>false, "log_level"=>"INFO", "node_name"=>"ip-10-40-22-237.ec2.internal", "ui_dir"=>"/srv/consul-ui/current/dist", "recursors"=>[""]}

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

This comment has been minimized.

Copy link

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

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]
    subscribes :restart, %|file[#{node['gz-consul']['config_path']}|, :delayed unless service_status.any? { |x| [:disable].include?(x) }
    action service_status
  ignore_failure true if node['gz-consul']['nuke']

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

Hopefully helps!


This comment has been minimized.

Copy link
Member Author

majormoses commented Oct 9, 2015

@scalp42 thanks let me take a crack at it.


This comment has been minimized.

Copy link
Member Author

majormoses commented Oct 9, 2015

@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.

@majormoses majormoses closed this Oct 9, 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.