From f821ea59abbfdaad05703bd659a577b0935a7347 Mon Sep 17 00:00:00 2001 From: Philip Garrett Date: Sat, 4 Jun 2016 19:28:29 -0400 Subject: [PATCH 1/4] Fix attribute type mismatch This quells a warning about "Option environment must be a kind of [String]" that gets emitted during rspec runs. Chef 13 will not allow the type mismatch. --- libraries/consul_execute.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/consul_execute.rb b/libraries/consul_execute.rb index 4a24c569..75a4f232 100644 --- a/libraries/consul_execute.rb +++ b/libraries/consul_execute.rb @@ -16,7 +16,7 @@ class ConsulExecute < Chef::Resource default_action(:run) attribute(:command, kind_of: String, name_attribute: true) - attribute(:environment, kind_of: String, default: { 'PATH' => '/usr/local/bin:/usr/bin:/bin' }) + attribute(:environment, kind_of: Hash, default: { 'PATH' => '/usr/local/bin:/usr/bin:/bin' }) attribute(:options, option_collector: true, default: {}) action(:run) do From f6cc3da4a0dd9ca085164b340086c8319d05fb8c Mon Sep 17 00:00:00 2001 From: Philip Garrett Date: Sat, 4 Jun 2016 19:30:45 -0400 Subject: [PATCH 2/4] Use correct attribute for default config_dir The consul_service resource was using a default value attribute that was not configured anywhere. This changes it to use the same default as consul_config. --- libraries/consul_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/consul_service.rb b/libraries/consul_service.rb index 0da2b834..5a9db0b4 100644 --- a/libraries/consul_service.rb +++ b/libraries/consul_service.rb @@ -38,7 +38,7 @@ class ConsulService < Chef::Resource attribute(:data_dir, kind_of: String, default: lazy { node['consul']['config']['data_dir'] }) # @!attribute config_dir # @return [String] - attribute(:config_dir, kind_of: String, default: lazy { node['consul']['config']['config_dir'] }) + attribute(:config_dir, kind_of: String, default: lazy { node['consul']['service']['config_dir'] }) # @!attribute nssm_params # @return [String] attribute(:nssm_params, kind_of: Hash, default: lazy { node['consul']['service']['nssm_params'] }) From 49dbde591594ae6c158cb871db862ff060c89476 Mon Sep 17 00:00:00 2001 From: Philip Garrett Date: Sun, 5 Jun 2016 11:26:19 -0400 Subject: [PATCH 3/4] Fix kitchen tests for default-centos-511 On my system, this fixes the following failures under Centos 5: 1) Service "consul" should be enabled Failure/Error: it { should be_enabled } expected Service "consul" to be enabled /bin/sh -c chkconfig\ --list\ consul\ \|\ grep\ 3:on # /tmp/verifier/suites/serverspec/default_spec.rb:26:in `block (2 levels) in ' 2) Service "consul" should be running Failure/Error: it { should be_running } expected Service "consul" to be running /bin/sh -c service\ consul\ status # /tmp/verifier/suites/serverspec/default_spec.rb:27:in `block (2 levels) in ' --- templates/default/sysvinit.service.erb | 2 +- test/integration/helpers/serverspec/spec_helper.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/templates/default/sysvinit.service.erb b/templates/default/sysvinit.service.erb index f17bdcc1..5a82f086 100755 --- a/templates/default/sysvinit.service.erb +++ b/templates/default/sysvinit.service.erb @@ -64,7 +64,7 @@ _start() { daemon \ --pidfile=$pidfile \ --user=$user \ - " { $exec <%= @daemon_options %> &>> $logfile & } ; echo \$! >| $pidfile " + " { $exec <%= @daemon_options %> > $logfile 2>&1 & } ; echo \$! >| $pidfile " RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $lockfile diff --git a/test/integration/helpers/serverspec/spec_helper.rb b/test/integration/helpers/serverspec/spec_helper.rb index c1fddf06..c606a37c 100644 --- a/test/integration/helpers/serverspec/spec_helper.rb +++ b/test/integration/helpers/serverspec/spec_helper.rb @@ -6,3 +6,12 @@ set :backend, :cmd set :os, family: 'windows' end + +# Tells serverspec to use a login shell for running chkconfig/service, +# which prevents false error reports on Centos 5. +begin + if File.read("/etc/redhat-release") =~ /release 5\./ + Specinfra.configuration.login_shell = true + end +rescue SystemCallError +end From 93379ac8a3541af923a0ddcbfe1ce29b0dbae8e4 Mon Sep 17 00:00:00 2001 From: Philip Garrett Date: Thu, 9 Jun 2016 21:36:26 -0400 Subject: [PATCH 4/4] Append log instead of overwriting it --- templates/default/sysvinit.service.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/default/sysvinit.service.erb b/templates/default/sysvinit.service.erb index 5a82f086..552b821e 100755 --- a/templates/default/sysvinit.service.erb +++ b/templates/default/sysvinit.service.erb @@ -64,7 +64,7 @@ _start() { daemon \ --pidfile=$pidfile \ --user=$user \ - " { $exec <%= @daemon_options %> > $logfile 2>&1 & } ; echo \$! >| $pidfile " + " { $exec <%= @daemon_options %> >> $logfile 2>&1 & } ; echo \$! >| $pidfile " RETVAL=$? echo [ $RETVAL -eq 0 ] && touch $lockfile