Skip to content

Commit

Permalink
Added support for stopping service prior to deleting binary to then b…
Browse files Browse the repository at this point in the history
…e 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.
  • Loading branch information
asasfu committed Aug 10, 2015
1 parent 4634f0f commit 707af3f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "KyleAnderson-consul",
"version": "1.0.1",
"version": "1.0.2",
"author": "Kyle Anderson <kyle@xkyle.com>",
"summary": "Configures Consul by Hashicorp",
"license": "Apache-2.0",
Expand Down

0 comments on commit 707af3f

Please sign in to comment.