sous-chefs / consul Goto Github PK
View Code? Open in Web Editor NEWDevelopment repository for the consul cookbook
Home Page: https://supermarket.chef.io/cookbooks/consul
License: Apache License 2.0
Development repository for the consul cookbook
Home Page: https://supermarket.chef.io/cookbooks/consul
License: Apache License 2.0
Right now, the only way to create a check it to set-up a service. Because with my current stack,
it's much easier to just add some check:
refs: https://consul.io/docs/agent/checks.html
Currently there is no way to bootstrap a full cluster without creating the nodes first and update the ['consul']['servers'] array with the list of IPs.
I can work in some recipe to tag the nodes and use that tag to make a chef_search and when reached the number of servers needed, bootstrap the cluster.
metadata.rb lists the chef-provisioning cookbook as a dependency. But it seems like the only relation to chef-provisioning is that it is a recommended way to use consul-cookbook (via cluster.rb). Indeed the Usage docs for consul:
gem install chef-provisioning chef-provisioning-fog
export CHEF_DRIVER=fog:AWS
chef-client -z cluster.rb
does not use the chef-provisioning cookbook -- it uses a simple gem install. So it seems odd to make installing the chef-provisioning cookbook a requirement for using consul-cookbook.
If suggests
is broken, perhaps there is an alternative keyword like recommends
that would work instead? Or maybe the chef-provisioning cookbook doesn't belong in metadata.rb at all?
I attempted to wrap this cookbook and install consul v0.4.0 using install_method = 'source' and source_revision = 'v0.4.0'
My test-kitchen runs failed thusly:
- checkout ref e1d87dee26c05cea64342fadd2a728894b764aec branch v0.4.0
* golang_package[github.com/hashicorp/consul] action install[2014-09-14T16:04:35+00:00] INFO: Processing golang_package[github.com/hashicorp/consul] action install (consul::install_source line 34)
* bash[/usr/local/go/bin/go get -v github.com/hashicorp/consul 2> >(grep -v '(download)$' > /tmp/kitchen/cache/github.com-hashicorp-consul)] action run[2014-09-14T16:04:35+00:00] INFO: Processing bash[/usr/local/go/bin/go get -v github.com/hashicorp/consul 2> >(grep -v '(download)$' > /tmp/kitchen/cache/github.com-hashicorp-consul)] action run (/tmp/kitchen/cache/cookbooks/golang/providers/package.rb line 5)
================================================================================
Error executing action `run` on resource 'bash[/usr/local/go/bin/go get -v github.com/hashicorp/consul 2> >(grep -v '(download)$' > /tmp/kitchen/cache/github.com-hashicorp-consul)]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '2'
---- Begin output of "bash" "/tmp/chef-script20140914-1390-11gnv8z" ----
STDOUT:
STDERR:
---- End output of "bash" "/tmp/chef-script20140914-1390-11gnv8z" ----
Ran "bash" "/tmp/chef-script20140914-1390-11gnv8z" returned 2
I logged into the kitchen instalce and tried to run the go get command by hand and got this:
vagrant@default-ubuntu-1404:/tmp/kitchen/cache$ /usr/local/go/bin/go get -v github.com/hashicorp/consul
github.com/armon/gomdb
# github.com/armon/gomdb
exec: "gcc": executable file not found in $PATH
vagrant@default-ubuntu-1404:/tmp/kitchen/cache$
I then added 'package gcc' before including the consul recipe, and the kitchen test succeeded. It appears that the gomdb package, while not requiring the C library to be on the system, does need to compile C code to work properly.
Hi,
Sorry if this is obvious and I have missed it. Is there a way to add a service with multiple checks, rather than just one?
If so, what is the syntax?
Thanks!
What component depends on repoforge?
Standard "init" fails to start due to quoting of $CMD. Removing quotation marks fixes issue:
[root@server1 consul.d]# service consul start
Starting consul
Running: /usr/bin/consul agent -config-dir /etc/consul.d
Unable to start consul, see /var/log/consul.log
Logfile is empty but in messages:
Mar 20 21:50:06 server1 consul: /etc/init.d/consul: line 46: /usr/bin/consul agent -config-dir /etc/consul.d: No such file or directory
After removing quotation marks:
[root@server1 consul.d]# service consul start
Starting consul
The consul agent is sensitive to a HUP during its initialization process, such as when invoked via 'knife ssh'. Adding a nohup to the invocation or adding a sleep after it seems to clear up the issue.
I've opened an issue against consul itself as well.
Run consul as root, create a service definition, change the consul user to 'consul', and reconverge chef – consul fails to start since it doesn't have right permissions on the files inside the consul directories.
I'm still looking into what changed since I had this working last week. I'm getting this error now from the consul::install_binary recipe:
uninitialized constant Archive::EXTRACT_OWNER
Initial googling shows that it's related to the ruby gem that unzips files (libarchive I suppose). I don't believe the version of that has changed, but I can't be certain just yet. I thought it merited an issue in this cookbook repo since it might happen to others. I'll add more info if I get it. If anyone has any suggestions, that would be great.
This happens on centos 6.5
It seems that the error is caused by the installation of the json file inside the _services.rb file just before the installation of the service itself.
If the jsonfile block is moved after the service installation block then the error dissapears
Instead of kill $PID
, stopping should send SIGINT, therefore kill -INT $PID
, which will gracefully leave the cluster. kill
's default signal is SIGTERM if I'm not mistaken. I'll make a PR for this if necessary.
I'm seeing that a when chef'ing a new node, consul is not shutting down during a /etc/init.d/consul restart and is breaking the bootstrap. The init script 'stop' should enforce that the process be killed by the end of the script rather than giving up and returning a non-0 exit code, by sending a kill -9 if the process hasn't gone down in the provided time.
This is related to #72, but is a slightly different issue so want to treated it as such.
Based on the documentation the client_addr
configuration element is what controls what IP's the service will bind to. When not set this defaults to 127.0.0.1. manually adding this element to the json configuration and restarting the service shows this to be the case.
I think the client_addr
attribute needs to get added to the copy param in order to have the service listening on all available interfaces. Setting the bind_addr
doesn't result in the service listening on anything except 127.0.0.1
I'd like to avoid installing compilers and other build tools on production servers. But the ::install_binary recipe causes compilers and other tools to get installed via apt (testing on ubuntu 12.04). It looks like this is caused by the libarchive cookbook dependency, which compiles the libarchive library as part of the ruby gem install. Due to the compiler install, I can't use the cookbook to install consul on production servers...
> kitchen converge default-ubuntu-1204
...
Recipe: build-essential::_debian
* apt_package[autoconf] action install
- install version 2.68-1ubuntu2 of package autoconf
* apt_package[binutils-doc] action install
- install version 2.22-6ubuntu1.3 of package binutils-doc
* apt_package[bison] action install
- install version 1:2.5.dfsg-2.1 of package bison
* apt_package[build-essential] action install (up to date)
* apt_package[flex] action install
- install version 2.5.35-10ubuntu3 of package flex
* apt_package[gettext] action install
- install version 0.18.1.1-5ubuntu3 of package gettext
* apt_package[ncurses-dev] action install
- install version (none) of package ncurses-dev
...
The docs say you can use ['consul']['client_address'] to start the UI, however the -ui-dir isn't anywhere in the config.
I'd really like to install consul on my windows web servers.
Are there any plans to add windows support?
I'm pretty new to chef, and I'm not a windows expert. I'm debating how big of a task this would be.
file[/etc/consul.d/default.json] action create (up to date)
template[/etc/sysconfig/consul] action create (up to date)
template[/etc/init.d/consul] action create (up to date)
service[consul] action enable (up to date)
service[consul] action start
start
on resource 'service[consul]'Expected process to exit with [0], but received '1'
@johnbellone I'm not sure what the issue here is
My Vagrantfile configuration:
config.vm.define "cs1", primary: true do |cs1|
cs1.vm.hostname = "cs1.cida.vagrantup.com"
cs1.vm.network "private_network", ip: "10.0.0.10"
cs1.vm.provision :chef_zero do |chef|
chef.data_bags_path = "data_bags"
chef.json.merge!({
:consul => {
"servers" => ["10.0.0.10","10.0.0.11","10.0.0.12"],
"service_mode" => "cluster"
}
})
chef.run_list = ["consul::default"] end
end
==> cs1: [2015-01-12T19:02:02+00:00] INFO: service[consul] restarted
==> cs1: [2015-01-12T19:02:02+00:00] INFO: service[consul] enabled
==> cs1: [2015-01-12T19:02:02+00:00] INFO: directory[/usr/local/consul_ui-0.4.1] created directory /usr/local/consul_ui-0.4.1
==> cs1: [2015-01-12T19:02:04+00:00] INFO: remote_file[/var/chef/cache/consul_ui-0.4.1.zip] created file /var/chef/cache/consul_ui-0.4.1.zip
==> cs1: [2015-01-12T19:02:04+00:00] INFO: remote_file[/var/chef/cache/consul_ui-0.4.1.zip] updated file contents /var/chef/cache/consul_ui-0.4.1.zip
==> cs1: [2015-01-12T19:02:04+00:00] INFO: remote_file[/var/chef/cache/consul_ui-0.4.1.zip] not queuing delayed action run on executeunpack /var/chef/cache/consul_ui-0.4.1.zip, as it's already been queued
==> cs1: [2015-01-12T19:02:04+00:00] INFO: link[/var/lib/consul/ui] created
==> cs1: [2015-01-12T19:02:04+00:00] INFO: directory[/usr/local/consul_ui-0.4.1] sending run action to executeunpack /var/chef/cache/consul_ui-0.4.1.zip
==> cs1: [2015-01-12T19:02:04+00:00] INFO: execute[unpack /var/chef/cache/consul_ui-0.4.1.zip] ran successfully
==> cs1: [2015-01-12T19:02:04+00:00] INFO: execute[unpack /var/chef/cache/consul_ui-0.4.1.zip] sending run action to executeset owner on /usr/local/consul_ui-0.4.1
==> cs1: [2015-01-12T19:02:04+00:00] INFO: execute[set owner on /usr/local/consul_ui-0.4.1] ran successfully
==> cs1: [2015-01-12T19:02:04+00:00] INFO: file[/etc/consul.d/default.json] sending restart action to serviceconsul
==> cs1:
==> cs1: ================================================================================
==> cs1: Error executing action restart
on resource 'service[consul]'
==> cs1: ================================================================================
==> cs1:
==> cs1:
==> cs1: Mixlib::ShellOut::ShellCommandFailed
==> cs1: ------------------------------------
==> cs1: Expected process to exit with [0], but received '1'
==> cs1:
==> cs1: ---- Begin output of /sbin/service consul restart ----
==> cs1:
==> cs1: STDOUT: Stopping consul.............
==> cs1:
==> cs1: consul not stopped; may still be shutting down or shutdown may have failed
==> cs1:
==> cs1: Unable to stop consul, will not attempt to start
==> cs1:
==> cs1: STDERR:
==> cs1:
==> cs1: ---- End output of /sbin/service consul restart ----
==> cs1:
==> cs1: Ran /sbin/service consul restart returned 1
==> cs1:
==> cs1:
==> cs1: Resource Declaration:
==> cs1: ---------------------
==> cs1: # In /tmp/vagrant-chef/83bff0467b4d77d5a69d8ce31da32616/cookbooks/consul/recipes/_service.rb
==> cs1:
==> cs1: 211: service 'consul' do
==> cs1: 212: provider Chef::Provider::Service::Upstart if platform?("ubuntu")
==> cs1: 213: supports status: true, restart: true, reload: true
==> cs1: 214: action [:enable, :start]
==> cs1: 215: subscribes :restart, "file[#{consul_config_filename}", :delayed
==> cs1: 216: end
==> cs1: 217: when 'runit'
==> cs1:
==> cs1: Compiled Resource:
==> cs1: ------------------
==> cs1: # Declared in /tmp/vagrant-chef/83bff0467b4d77d5a69d8ce31da32616/cookbooks/consul/recipes/_service.rb:211:in `from_file'
==> cs1:
==> cs1: service("consul") do
==> cs1: action [:enable, :start]
==> cs1: updated true
==> cs1: supports {:status=>true, :restart=>true, :reload=>true}
==> cs1: retries 0
==> cs1: retry_delay 2
==> cs1: default_guard_interpreter :default
==> cs1: service_name "consul"
==> cs1: enabled true
==> cs1: running true
==> cs1: pattern "consul"
==> cs1: declared_type :service
==> cs1: cookbook_name :consul
==> cs1: recipe_name "_service"
==> cs1: end
==> cs1:
==> cs1: [2015-01-12T19:02:15+00:00] ERROR: Running exception handlers
==> cs1: [2015-01-12T19:02:15+00:00] ERROR: Exception handlers complete
==> cs1: [2015-01-12T19:02:15+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> cs1: [2015-01-12T19:02:15+00:00] ERROR: service[consul](consul::_service line 211) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
==> cs1: ---- Begin output of /sbin/service consul restart ----
==> cs1: STDOUT: Stopping consul.............
==> cs1: consul not stopped; may still be shutting down or shutdown may have failed
==> cs1: Unable to stop consul, will not attempt to start
==> cs1: STDERR:
==> cs1: ---- End output of /sbin/service consul restart ----
==> cs1: Ran /sbin/service consul restart returned 1
==> cs1: [2015-01-12T19:02:16+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
The ouput:
Generated at 2015-01-12 19:02:15 +0000
Mixlib::ShellOut::ShellCommandFailed: service[consul](consul::_service line 211) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /sbin/service consul restart ----
STDOUT: Stopping consul.............
consul not stopped; may still be shutting down or shutdown may have failed
Unable to stop consul, will not attempt to start
STDERR:
---- End output of /sbin/service consul restart ----
Ran /sbin/service consul restart returned 1
/opt/chef/embedded/lib/ruby/gems/2.1.0/gems/mixlib-shellout-2.0.0/lib/mixlib/shellout.rb:267:in invalid!' /opt/chef/embedded/lib/ruby/gems/2.1.0/gems/mixlib-shellout-2.0.0/lib/mixlib/shellout.rb:254:in
error!'
/opt/chef/embedded/apps/chef/lib/chef/mixin/shell_out.rb:60:in shell_out_with_systems_locale!' /opt/chef/embedded/apps/chef/lib/chef/provider/service/init.rb:75:in
restart_service'
/opt/chef/embedded/apps/chef/lib/chef/provider/service.rb:115:in block in action_restart' /opt/chef/embedded/apps/chef/lib/chef/mixin/why_run.rb:52:in
call'
/opt/chef/embedded/apps/chef/lib/chef/mixin/why_run.rb:52:in add_action' /opt/chef/embedded/apps/chef/lib/chef/provider.rb:180:in
converge_by'
/opt/chef/embedded/apps/chef/lib/chef/provider/service.rb:114:in action_restart' /opt/chef/embedded/apps/chef/lib/chef/provider.rb:145:in
run_action'
/opt/chef/embedded/apps/chef/lib/chef/resource.rb:582:in run_action' /opt/chef/embedded/apps/chef/lib/chef/runner.rb:49:in
run_action'
/opt/chef/embedded/apps/chef/lib/chef/runner.rb:111:in run_delayed_notification' /opt/chef/embedded/apps/chef/lib/chef/runner.rb:99:in
block in run_delayed_notifications'
/opt/chef/embedded/apps/chef/lib/chef/runner.rb:98:in each' /opt/chef/embedded/apps/chef/lib/chef/runner.rb:98:in
run_delayed_notifications'
/opt/chef/embedded/apps/chef/lib/chef/runner.rb:88:in converge' /opt/chef/embedded/apps/chef/lib/chef/client.rb:315:in
converge'
/opt/chef/embedded/apps/chef/lib/chef/client.rb:400:in block in run' /opt/chef/embedded/apps/chef/lib/chef/client.rb:399:in
catch'
/opt/chef/embedded/apps/chef/lib/chef/client.rb:399:in run' /opt/chef/embedded/apps/chef/lib/chef/application.rb:261:in
block in fork_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:249:in fork' /opt/chef/embedded/apps/chef/lib/chef/application.rb:249:in
fork_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:215:in block in run_chef_client' /opt/chef/embedded/apps/chef/lib/chef/local_mode.rb:38:in
with_server_connectivity'
/opt/chef/embedded/apps/chef/lib/chef/application.rb:201:in run_chef_client' /opt/chef/embedded/apps/chef/lib/chef/application/solo.rb:245:in
block in interval_run_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/application/solo.rb:234:in loop' /opt/chef/embedded/apps/chef/lib/chef/application/solo.rb:234:in
interval_run_chef_client'
/opt/chef/embedded/apps/chef/lib/chef/application/solo.rb:224:in run_application' /opt/chef/embedded/apps/chef/lib/chef/application.rb:58:in
run'
/opt/chef/embedded/apps/chef/bin/chef-solo:25:in <top (required)>' /usr/bin/chef-solo:40:in
load'
/usr/bin/chef-solo:40:in `
Consul 0.5.0 has been released, so the new archive checksums need to be added.
Binary installs on CentOS 5.10 and 6.5 install the binary, but it's unable to be run due to glibc incompatibilities:
[vagrant@binary-centos-65 ~]$ sudo /usr/local/bin/consul
/usr/local/bin/consul: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/local/bin/consul)
My thought to fix this is to have the default recipe do install by package on ubuntu and source on centos. This way default should always work. I'd then throw excludes in .kitchen.yml
for binary/centos. Thoughts?
End of output of kitchen test source-ubuntu-1204
[2014-04-24T22:10:26+00:00] INFO: directory[/usr/local/consul-1] sending run action to execute[unpack /tmp/kitchen/cache/consul-1.tar.gz] (delayed)
* execute[unpack /tmp/kitchen/cache/consul-1.tar.gz] action run[2014-04-24T22:10:26+00:00] INFO: Processing execute[unpack /tmp/kitchen/cache/consul-1.tar.gz] action run (/tmp/kitchen/cache/cookbooks/ark/providers/default.rb line 281)
================================================================================
Error executing action `run` on resource 'execute[unpack /tmp/kitchen/cache/consul-1.tar.gz]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '2'
---- Begin output of /bin/tar xzf /tmp/kitchen/cache/consul-1.tar.gz --strip-components=1 ----
STDOUT:
STDERR: tar (child): gzip: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
/bin/tar: Child returned status 2
/bin/tar: Error is not recoverable: exiting now
---- End output of /bin/tar xzf /tmp/kitchen/cache/consul-1.tar.gz --strip-components=1 ----
Ran /bin/tar xzf /tmp/kitchen/cache/consul-1.tar.gz --strip-components=1 returned 2
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/ark/providers/default.rb
281: execute "unpack #{new_resource.release_file}" do
282: command _unpack_command
283: cwd new_resource.path
284: environment new_resource.environment
285: notifies :run, "execute[set owner on #{new_resource.path}]"
286: notifies :run, "execute[autogen #{new_resource.path}]"
287: notifies :run, "execute[configure #{new_resource.path}]"
288: notifies :run, "execute[make #{new_resource.path}]"
289: notifies :run, "execute[make install #{new_resource.path}]"
290: action :nothing
291: end
292:
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/ark/providers/default.rb:281:in `block in class_from_file'
execute("unpack /tmp/kitchen/cache/consul-1.tar.gz") do
action [:nothing]
retries 0
retry_delay 2
guard_interpreter :default
command "/bin/tar xzf /tmp/kitchen/cache/consul-1.tar.gz --strip-components=1"
backup 5
cwd "/usr/local/consul-1"
environment {"PATH"=>"/usr/local/bin:/opt/go/bin:/usr/bin", "GOPATH"=>"/opt/go"}
returns 0
cookbook_name "consul"
end
================================================================================
Error executing action `install_with_make` on resource 'ark[consul]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
execute[unpack /tmp/kitchen/cache/consul-1.tar.gz] (/tmp/kitchen/cache/cookbooks/ark/providers/default.rb line 281) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '2'
---- Begin output of /bin/tar xzf /tmp/kitchen/cache/consul-1.tar.gz --strip-components=1 ----
STDOUT:
STDERR: tar (child): gzip: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
/bin/tar: Child returned status 2
/bin/tar: Error is not recoverable: exiting now
---- End output of /bin/tar xzf /tmp/kitchen/cache/consul-1.tar.gz --strip-components=1 ----
Ran /bin/tar xzf /tmp/kitchen/cache/consul-1.tar.gz --strip-components=1 returned 2
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/consul/recipes/source_install.rb
28: ark 'consul' do
29: environment env
30: url URI.join('https://github.com/hashicorp/consul/archive/', "#{source_version}.tar.gz").to_s
31: action [:install_with_make]
32: end
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cache/cookbooks/consul/recipes/source_install.rb:28:in `from_file'
ark("consul") do
provider Chef::Provider::Ark
action [:install_with_make]
updated true
updated_by_last_action true
retries 0
retry_delay 2
guard_interpreter :default
cookbook_name "consul"
recipe_name "source_install"
environment {"PATH"=>"/usr/local/bin:/opt/go/bin:/usr/bin", "GOPATH"=>"/opt/go"}
url "https://github.com/hashicorp/consul/archive/v0.1.0.tar.gz"
extension "tar.gz"
prefix_bin "/usr/local/bin"
version "1"
path "/usr/local/consul-1"
home_dir "/usr/local/consul"
release_file "/tmp/kitchen/cache/consul-1.tar.gz"
strip_components 1
owner "root"
group 0
end
[2014-04-24T22:10:26+00:00] INFO: Running queued delayed notifications before re-raising exception
Running handlers:
[2014-04-24T22:10:26+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-04-24T22:10:26+00:00] ERROR: Exception handlers complete
[2014-04-24T22:10:26+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
Chef Client failed. 10 resources updated in 305.371971911 seconds
[2014-04-24T22:10:26+00:00] ERROR: ark[consul] (consul::source_install line 28) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[unpack /tmp/kitchen/cache/consul-1.tar.gz] (/tmp/kitchen/cache/cookbooks/ark/providers/default.rb line 281) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '2'
---- Begin output of /bin/tar xzf /tmp/kitchen/cache/consul-1.tar.gz --strip-components=1 ----
STDOUT:
STDERR: tar (child): gzip: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
/bin/tar: Child returned status 2
/bin/tar: Error is not recoverable: exiting now
---- End output of /bin/tar xzf /tmp/kitchen/cache/consul-1.tar.gz --strip-components=1 ----
Ran /bin/tar xzf /tmp/kitchen/cache/consul-1.tar.gz --strip-components=1 returned 2
[2014-04-24T22:10:26+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>>>>>> Converge failed on instance <source-ubuntu-1204>.
>>>>>> Please see .kitchen/logs/source-ubuntu-1204.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sudo -E chef-client -z --config /tmp/kitchen/client.rb --log_level info --json-attributes /tmp/kitchen/dna.json]
>>>>>> ----------------------
I have the same results with any of the source installs. I also tried using ark version 0.8.0 rather than the latest 0.8.2, which had the same results. Are you also seeing this?
The file resource in install_binary which is intended to change the permissions of the installed binary also changes the mod_date of the executable to the current date. E.g.: if I install an older version of consul in 2014 December, which has mod_date of 2014 August, the file resource will change the mod_date to 2014 December. Now if I want to install a newer version that was released e.g in 2014 November, the unzip step of the ark resource will not overwrite the older version executable as it has newer mod_date than the newer version (2014 Dec vs 2014 Nov).
As I explained at length in #135 , I shot myself in the foot by missing the Getting Started section. I saw Usage, it only mentioned chef-provisioning which I didn't want to use (cause we autoscale) and by the time I was reading LWRP definitions, I assumed all that would follow was more of that (which I would look at more closely once I had a cluster running) and perhaps a "contributing" section.
Additionally, in the process of debugging I got as far as setting bootstrap_expect
manually and finding that it wasn't getting written to my config. This is because I was using server
rather than cluster
for my service mode. I didn't understand the difference on account of being unaware of the getting started section.
As of 0.9.0, a user will likely figure out the semantics by the time they get a cluster working, but once Atlas autojoin is merged the failure to set bootstrap_expect
with server
is likely to confuse more users. (since Atlas will let consul members
return correctly - but no leader will be elected).
The documentation indicates that a databag item with the key 'ca_file' will become the contents of /etc/consul.d/ca.pem, however the key actually needs to be 'ca_cert'.
https://github.com/johnbellone/consul-cookbook/blob/master/resources/check_def.rb#L31
I think that names usually/often contain spaces, as they do in the examples here https://consul.io/docs/agent/checks.html and in "Serf Health Status". Wouldn't it be better to use id - "serfHealth" - as part of the name of the file instead?
The error
resource file[/etc/consul.d/service-consul.json] is configured to notify resource service[consul] with action reload, but service[consul] cannot be found in the resource collection. file[/etc/consul.d/service-consul.json] is defined in /var/chef/cache/cookbooks/consul/providers/service_def.rb:27:in `block (2 levels) in class_from_file'
My code:
node['sensiolabs_consul']['services'].each do |name, definition|
consul_service_def name do
id definition['id'] unless definition['id'].nil?
port definition['port'] unless definition['port'].nil?
tags definition['tags'] unless definition['tags'].nil?
check definition['check'] unless definition['check'].nil?
end
end
I used init
for service configuration
I am trying to get consul to work on Centos70, which worked in Vagrant, so I packer'd up a centos7 ami and launched with recipe[consul]
and custom json
"consul": {
"install_method": "binary",
"init_style": "systemd"
}
things seemed ok, but it just hangs endlessly
* template[/etc/sv/consul/log/config] action create
- create new file /etc/sv/consul/log/config
- update content in file /etc/sv/consul/log/config from none to e3b0c4
(no diff)
- change mode from '' to '0644'
- restore selinux security context
* link[/etc/init.d/consul] action create
- create symlink at /etc/init.d/consul to /sbin/sv
- configure service runit_service[consul]
* link[/etc/service/consul] action create
- create symlink at /etc/service/consul to /etc/sv/consul
does anyone have a working combination of centos66 or centos7 + consul working?
I was thinking about adding an LWRP (consul_kv
) to allow for idempotent puts and deletes into the KV store. Before I go down that path is there enough interest to warrant it/would a PR get accepted?
Thanks
Hello.
On every nodes, during the very first chef-client, I got this:
---- Begin output of /etc/init.d/consul restart ----
STDOUT: Stopping consul....
consul not stopped; may still be shutting down or shutdown may have failed
Unable to stop consul, will not attempt to start
STDERR:
---- End output of /etc/init.d/consul restart ----
This occurs when consul is installed for the very first time. It does not occur anymore for run N>=2
As you can see, I'm using init
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.
/etc/consul.d/web.conf
ect..Is there something that I am missing? Whats the best way to deploy different configs to different servers?
What is the purpose of this dependency? It appears to only be referenced in the Kitchen configuration. Including this forces Yum 3.0 cookbook in the dependency tree, which is difficult to migrate to from 2.0 in a large installation.
What do you guys think about adding support for dnsmasq in separate recipe? I can submit a pull request.
I'd like to change the DNS port Consul listens on. If I include the following for extra_params
:
default['consul']['extra_params'] = { 'ports' => { 'dns' => 53 }, 'recursor' => '8.8.8.8' }
The resulting default.json
is:
{
"ports": {
"dns": 53
},
"recursor": "8.8.8.8",
"data_dir": "/var/lib/consul",
"server": true,
"ports": {
"dns": 8600,
"http": 8500,
"rpc": 8400,
"serf_lan": 8301,
"serf_wan": 8302,
"server": 8300
}
}
And the consul service fails to start.
When the init_style is runit no user is created. But then when any of resources are used (ie, consul_service_def) they try to use node['consul']'service_user'.
For some reason, chef-provisioning has been added to metadata.rb as a dependency. While I understand chef-provisioning is used for testing this cookbook, I don't see the need for it to be in metadata.rb. If anything, it should be in the Gemfile. Please remove this dep.
It would be great if someone could put together a howto on getting a consul.io cluster going from scratch with Chef. It's not immediately obvious how to start up a cluster using this cookbook and whether nodes should be started in bootstrap
mode or server
mode or how bootstrap_expect
should be used.
I'm not sure if this is by design or not, so feel free to close if it is.
I noticed today that when you apply a new configuration, the consul service is not restarted. Specifically in my case today, I had originally spun up the service using all the defaults and found the service was listening on 127.0.0.1
. So i then set node.default[:consul][:bind_addr] = '0.0.0.0'
and re-ran Chef. The configuration file on disk was updated, but the service didn't get restarted. Thoughts on adding a notifies :restart, "service[consul]"
to the configuration file resource?
If I add the consul UI recipe, I would expect that the init scripts would add the -ui option to the start script.
Current init script
...
/usr/local/bin/consul agent -config-dir /etc/consul.d
Expected init script
...
/usr/local/bin/consul agent -config-dir /etc/consul.d -ui-dir /opt/consul_ui/0.5.1/dist/
Is this by design?
It looks like you might be able to load the UI in the config file as a work around.
Errno::EISDIR: file[/var/lib/consul/ui] (consul::ui line 32) had an error: Errno::EISDIR: Is a directory - read
/opt/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1372:in `copy_stream'
/opt/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1372:in `block (2 levels) in copy_file'
/opt/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1371:in `open'
/opt/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1371:in `block in copy_file'
/opt/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1370:in `open'
/opt/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1370:in `copy_file'
/opt/chef/embedded/lib/ruby/1.9.1/fileutils.rb:477:in `copy_file'
/opt/chef/embedded/lib/ruby/1.9.1/fileutils.rb:396:in `block in cp'
/opt/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1515:in `block in fu_each_src_dest'
/opt/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1531:in `fu_each_src_dest0'
/opt/chef/embedded/lib/ruby/1.9.1/fileutils.rb:1513:in `fu_each_src_dest'
/opt/chef/embedded/lib/ruby/1.9.1/fileutils.rb:395:in `cp'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/util/backup.rb:70:in `do_backup'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/util/backup.rb:32:in `backup!'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/provider/file.rb:332:in `do_backup'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/provider/file.rb:138:in `block in action_delete'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/mixin/why_run.rb:52:in `call'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/mixin/why_run.rb:52:in `add_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/provider.rb:156:in `converge_by'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/provider/file.rb:137:in `action_delete'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/provider.rb:121:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource.rb:648:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/runner.rb:49:in `run_action'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/runner.rb:81:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/runner.rb:81:in `each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/runner.rb:81:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource_collection.rb:98:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/resource_collection.rb:96:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/runner.rb:80:in `converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/client.rb:345:in `converge'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/client.rb:431:in `do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/client.rb:213:in `block in run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/client.rb:207:in `fork'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/client.rb:207:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/application.rb:236:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/application/client.rb:338:in `block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/application/client.rb:327:in `loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/application/client.rb:327:in `run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/lib/chef/application.rb:55:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6/bin/chef-client:26:in `<top (required)>'
/usr/bin/chef-client:23:in `load'
/usr/bin/chef-client:23:in `<main>'
What do you think of moving the consul_directories.each
block from _service.rb
to the install_*.rb
recipes? That way, consul::install_binary
could be run in an initial setup step, monitored services could be added to that directory, and later on the consul service could be enabled and started in a later step without needing to fuss with creating node['consul']['config_dir']
for every service.
I'd be happy to create a PR if you'd like.
Thanks for this great cookbook regardless!
Setting the following consul attributes fails.
"encrypt_enabled": true,
"encrypt": "{{user `consul_encrypt`}}",
"ca_file": "/etc/consul.d/ssl/ca.cert",
"cert_file": "/etc/consul.d/ssl/consul.cert",
"key_file": "/etc/consul.d/ssl/consul.key",
"verify_incoming": true,
"verify_outgoing": true,
Data Bag Items must contain a Hash or Mash!
No secret specified and no secret found at /etc/chef/encrypted_data_bag_secret
I had to create a "consul" databag with a "encrypt" item.
cat data_bags/consul/encrypt.json
{
"id": "encrypt"
}
Also had to provide the secret file. Which is kinda weird. The reason for using attributes is so i don't have to create a databag. However, it seems one is required regardless. People might think that this type of data should be encrypted in a databag. However, if i am using chef-solo from a packer template to create a image then I can provide all this data from environment variables to packer.
I'm trying to use a LWRP to just add a check to a server. The documentation has examples of how to do this with services and checks, but not just the consul_check
provider.
Here is the consul_service_def
that works
consul_service_def 'influx web interface 8083' do
check(
id: 'Web interface',
name: 'Web interface on port 8083',
http: 'http://localhost:8083',
interval: '10s',
timeout: '1s'
)
notifies :reload, 'service[consul]'
end
Which succesfully translates to
{
"service": {
"name": "influx web interface 8083",
"check": {
"id": "Web interface",
"name": "Web interface on port 8083",
"http": "http://localhost:8083",
"interval": "10s",
"timeout": "1s"
}
}
}
However, this is what I am trying to do with the check_def provider
consul_check_def 'server1' do
id 'Web interface'
name 'Web interface on port 8083'
http 'http://localhost:80'
interval '10s'
timeout '1s'
notifies :reload, 'service[consul]'
end
This errors out
================================================================================
Recipe Compile Error in /var/chef/cache/cookbooks/ND-consul-agent/recipes/influxdb.rb
================================================================================
NoMethodError
-------------
undefined method `zero?' for "1s":String
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/ND-consul-agent/recipes/influxdb.rb:15:in `block in from_file'
/var/chef/cache/cookbooks/ND-consul-agent/recipes/influxdb.rb:10:in `from_file'
Relevant File Content:
----------------------
/var/chef/cache/cookbooks/ND-consul-agent/recipes/influxdb.rb:
8: # end
9:
10: consul_check_def 'server1' do
11: id 'Web interface'
12: name 'Web interface on port 8083'
13: http 'http://localhost:80'
14: interval '10s'
15>> timeout '1s'
16: notifies :reload, 'service[consul]'
17: end
18:
19: # {
20: # "check": {
21: # "id": "Web Interface ",
22: # "name": "Web Interface on port 8083",
23: # "http": "http://localhost:8083",
24: # "interval": "10s",
Running handlers:
[2015-05-26T15:46:04-06:00] ERROR: Running exception handlers
Running handlers complete
[2015-05-26T15:46:04-06:00] ERROR: Exception handlers complete
[2015-05-26T15:46:04-06:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated in 3.5705527 seconds
[2015-05-26T15:46:04-06:00] ERROR: undefined method `zero?' for "1s":String
[2015-05-26T15:46:04-06:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
I've also tried the following syntaxes:
consul_check_def 'foobar' do
id: 'Web interface',
name: 'Web interface on port 8083',
http: 'http://localhost:8083',
interval: '10s',
timeout: '1s'
notifies :reload, 'service[consul]'
end
consul_check_def 'foobar' do
check(
id: 'Web interface',
name: 'Web interface on port 8083',
http: 'http://localhost:8083',
interval: '10s',
timeout: '1s'
)
notifies :reload, 'service[consul]'
end
Whats the proper way to use the consul_check lwrp?
It looks like v0.4.2 has not been published to the Chef registry. Is there any particular reason for this, or would you mind publishing it? Thanks for all the work on this, I greatly appreciate it.
Per the current Consul docs:
The recommended way to bootstrap is to use the -bootstrap-expect configuration option. This options informs Consul of the expected number of server nodes, and automatically bootstraps when that many servers are available. To prevent inconsistencies and split-brain situations, all servers should specify the same value for -bootstrap-expect or specify no value at all. Any server that does not specify a value will not attempt to bootstrap the cluster.
Should there be a new ['consul']['service_mode']
setting for bootstrap-expect?
I'd be happy to tackle this and submit a PR if it's not a high priority for anybody else.
Please add an example of using the service LWRP to the Readme.
Does consul-cookbook actually require ark 0.8.0 or greater, or will an older version suffice?
latest git gives the following error:
* template[/etc/sysconfig/consul] action create[2014-10-28T00:50:48+00:00] INFO: Processing template[/etc/sysconfig/consul] action create (consul::_service line 134)
* Parent directory /etc/sysconfig does not exist.
================================================================================
Error executing action `create` on resource 'template[/etc/sysconfig/consul]'
================================================================================
Chef::Exceptions::EnclosingDirectoryDoesNotExist
------------------------------------------------
Parent directory /etc/sysconfig does not exist.
Resource Declaration:
---------------------
# In /tmp/kitchen/cache/cookbooks/consul/recipes/_service.rb
134: template '/etc/sysconfig/consul' do
135: source 'consul-sysconfig.erb'
136: mode 0755
137: notifies :create, 'template[/etc/init.d/consul]', :immediately
138: end
cloud Amazon EC2
Red Hat Enterprise Linux Server release 7.1 (Maipo)
consul-cookbook version 0.9.1
==> consul: package[libarchive-devel] (libarchive::default line 25) had an error: Chef::Exceptions::Package: No version specified, and no candidate version available for libarchive-devel
==> consul:
==> consul: Cookbook Trace:
==> consul: ---------------
==> consul: /tmp/vagrant-chef-2/chef-solo-1/cookbooks/libarchive/recipes/default.rb:27:in `from_file'
==> consul: /tmp/vagrant-chef-2/chef-solo-1/cookbooks/consul/recipes/install_binary.rb:18:in `from_file'
==> consul: /tmp/vagrant-chef-2/chef-solo-1/cookbooks/consul/recipes/default.rb:20:in `from_file'
==> consul: /tmp/vagrant-chef-2/chef-solo-1/cookbooks/rf-haproxy-consul/recipes/server.rb:11:in `from_file'
==> consul:
==> consul: Relevant File Content:
==> consul: ----------------------
==> consul: /tmp/vagrant-chef-2/chef-solo-1/cookbooks/libarchive/recipes/default.rb:
==> consul:
==> consul: 20: end.run_action(:install)
==> consul: 21: when platform_family?("rhel")
==> consul: 22: package "libarchive" do
==> consul: 23: action :nothing
==> consul: 24: end.run_action(:install)
==> consul: 25: package "libarchive-devel" do
==> consul: 26: action :nothing
==> consul: 27>> end.run_action(:install)
==> consul: 28: when platform_family?("arch")
==> consul: 29: package "libarchive" do
==> consul: 30: action :nothing
==> consul: 31: end.run_action(:install)
==> consul: 32: when platform_family?("mac_os_x")
==> consul: 33: package "libarchive" do
==> consul: 34: action :nothing
==> consul: 35: end.run_action(:install)
==> consul: 36: else
==> consul:
==> consul:
==> consul: Running handlers:
==> consul: [2015-04-21T11:40:45-04:00] ERROR: Running exception handlers
==> consul: Running handlers complete
==> consul: [2015-04-21T11:40:45-04:00] ERROR: Exception handlers complete
==> consul: [2015-04-21T11:40:45-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> consul: Chef Client failed. 0 resources updated in 29.007043215 seconds
==> consul: [2015-04-21T11:40:46-04:00] ERROR: package[libarchive-devel] (libarchive::default line 25) had an error: Chef::Exceptions::Package: No version specified, and no candidate version available for libarchive-devel
==> consul: [2015-04-21T11:40:46-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
AWS yum repo doesn't contain package libarchive-devel:
$ yum search libarchive
Loaded plugins: amazon-id, rhui-lb
=============================================== N/S matched: libarchive ================================================
libarchive.i686 : A library for handling streaming archive formats
libarchive.x86_64 : A library for handling streaming archive formats
I suggest to use cookbook ark instead of libarchive .
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.