From 707af3f303be931bfda112fc1c9117b58d0ec60c Mon Sep 17 00:00:00 2001 From: Adam S Date: Mon, 10 Aug 2015 14:31:31 -0700 Subject: [PATCH] Added support for stopping service prior to deleting binary to then be staged in Utilize puppet's provider to stop the service in a serialized fashion while also adding support for the pre-puppet 4.1.2? support addition for Ubuntu 15.04 and Fedora 22 by utilizing our init_style variable decision. Also bumped the version by one minor version bump to match this somewhat significant feature addition. --- manifests/install.pp | 14 +++++++++++++- metadata.json | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/manifests/install.pp b/manifests/install.pp index 22044d6a..51b8de3e 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -18,6 +18,18 @@ if $::operatingsystem != 'darwin' { ensure_packages(['unzip']) } + # This was done for puppet 3.x not supporting Ubuntu 15 and Fedora 22, and since this ruby line doesn't support site.pp... override of Service { provider => 'systemd' } + if versioncmp($::puppetversion, 4.2) < 0 { + $ruby_service_stop = $::operatingsystem ? { + 'fedora' => "ruby -r 'puppet' -e \"Puppet::Type.type(:service).newservice(:name => 'consul', :provider => '${consul::init_style}').provider.send('stop')\"", + 'ubuntu' => "ruby -r 'puppet' -e \"Puppet::Type.type(:service).newservice(:name => 'consul', :provider => '${consul::init_style}').provider.send('stop')\"", + default => "ruby -r 'puppet' -e \"Puppet::Type.type(:service).newservice(:name => 'consul').provider.send('stop')\"" + } + } else { + $ruby_service_stop = "ruby -r 'puppet' -e \"Puppet::Type.type(:service).newservice(:name => 'consul').provider.send('stop')\"" + } + + # This was done to make it so we don't have to do absolute paths in our unless inside staging::extract, since that module doesn't allow us to pass path => to it. Exec { provider => shell } @@ -26,7 +38,7 @@ } -> staging::extract { "${consul::real_download_file}": target => $consul::bin_dir, - unless => "which consul > /dev/null ; if [ $? = 0 ]; then test `consul version | grep -m1 -o [0-9\\.] | tr -d '\\n'` = ${consul::version}; unlessval=$?; if [ \$unlessval = 1 ]; then rm -f ${consul::bin_dir}/consul; fi; else unlessval=1; fi; test \$unlessval = 0", + unless => "which consul > /dev/null ; if [ $? = 0 ]; then test `consul version | grep -m1 -o [0-9\\.] | tr -d '\\n'` = ${consul::version}; unlessval=$?; if [ \$unlessval = 1 ]; then ${ruby_service_stop}; rm -f ${consul::bin_dir}/consul; fi; else unlessval=1; fi; test \$unlessval = 0", } -> file { "${consul::bin_dir}/consul": owner => 'root', diff --git a/metadata.json b/metadata.json index 207ece54..e61e4673 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "KyleAnderson-consul", - "version": "1.0.1", + "version": "1.0.2", "author": "Kyle Anderson ", "summary": "Configures Consul by Hashicorp", "license": "Apache-2.0",