Update poise-archive and poise-service cookbooks

This commit is contained in:
Greg Karékinian 2018-04-17 12:24:17 +02:00
parent 90bb872305
commit ff2f424ddb
16 changed files with 150 additions and 47 deletions

View File

@ -23,8 +23,8 @@ cookbook 'poise', '~> 2.8.1'
cookbook 'poise-languages', '~> 2.1.1' cookbook 'poise-languages', '~> 2.1.1'
cookbook 'poise-ruby', '~> 2.4.0' cookbook 'poise-ruby', '~> 2.4.0'
cookbook 'poise-javascript', '~> 1.2.0' cookbook 'poise-javascript', '~> 1.2.0'
cookbook 'poise-archive', '= 1.4.0' cookbook 'poise-archive', '~> 1.5.0'
cookbook 'poise-service', '= 1.4.2' cookbook 'poise-service', '~> 1.5.2'
cookbook 'users', '= 5.1.0' cookbook 'users', '= 5.1.0'
cookbook 'sudo', '= 3.5.0' cookbook 'sudo', '= 3.5.0'
cookbook 'hostname', '= 0.4.2' cookbook 'hostname', '= 0.4.2'

View File

@ -35,12 +35,12 @@ DEPENDENCIES
php (= 4.2.0) php (= 4.2.0)
php-fpm (= 0.7.9) php-fpm (= 0.7.9)
poise (= 2.8.1) poise (= 2.8.1)
poise-archive (= 1.4.0) poise-archive (~> 1.5.0)
poise-javascript (~> 1.2.0) poise-javascript (~> 1.2.0)
poise-languages (= 2.1.1) poise-languages (= 2.1.1)
poise-ruby (~> 2.4.0) poise-ruby (~> 2.4.0)
poise-ruby-build (= 1.1.0) poise-ruby-build (= 1.1.0)
poise-service (= 1.4.2) poise-service (~> 1.5.2)
postfix (= 5.0.2) postfix (= 5.0.2)
postgresql (= 6.1.1) postgresql (= 6.1.1)
redis redis
@ -151,7 +151,7 @@ GRAPH
apt (>= 0.0.0) apt (>= 0.0.0)
yum (>= 3.0) yum (>= 3.0)
poise (2.8.1) poise (2.8.1)
poise-archive (1.4.0) poise-archive (1.5.0)
poise (~> 2.6) poise (~> 2.6)
poise-build-essential (1.0.0) poise-build-essential (1.0.0)
poise (~> 2.6) poise (~> 2.6)
@ -172,7 +172,7 @@ GRAPH
poise-build-essential (~> 1.0) poise-build-essential (~> 1.0)
poise-git (~> 1.0) poise-git (~> 1.0)
poise-ruby (~> 2.1) poise-ruby (~> 2.1)
poise-service (1.4.2) poise-service (1.5.2)
poise (~> 2.0) poise (~> 2.0)
postfix (5.0.2) postfix (5.0.2)
postgresql (6.1.1) postgresql (6.1.1)

View File

@ -1,5 +1,10 @@
# Poise-Archive Changelog # Poise-Archive Changelog
## v1.5.0
* Support for 7-Zip unpacking archives on drives other than the system root.
* Chef 13 support.
## v1.4.0 ## v1.4.0
* Added support for using 7-Zip on Windows. * Added support for using 7-Zip on Windows.

View File

@ -112,12 +112,7 @@ module PoiseArchive
def move_files(tmpdir) def move_files(tmpdir)
entries_at_depth(tmpdir, new_resource.strip_components).each do |source| entries_at_depth(tmpdir, new_resource.strip_components).each do |source|
target = ::File.join(new_resource.destination, ::File.basename(source)) target = ::File.join(new_resource.destination, ::File.basename(source))
# If we are in keep_existing mode, the target might exist already. FileUtils.mv(source, target, secure: true)
# This is not a great solution and won't have exactly the same behavior
# as the other providers, but it's something at least.
FileUtils.rm_rf(target) if ::File.exist?(target)
# At some point this might need to fall back to a real copy.
::File.rename(source, target)
end end
end end

View File

@ -16,5 +16,5 @@
module PoiseArchive module PoiseArchive
VERSION = '1.4.0' VERSION = '1.5.0'
end end

View File

@ -1 +1 @@
{"name":"poise-archive","version":"1.4.0","description":"A Chef cookbook for unpacking file archives like tar and zip.","long_description":"# Poise-Archive Cookbook\n\n[![Build Status](https://img.shields.io/travis/poise/poise-archive.svg)](https://travis-ci.org/poise/poise-archive)\n[![Gem Version](https://img.shields.io/gem/v/poise-archive.svg)](https://rubygems.org/gems/poise-archive)\n[![Cookbook Version](https://img.shields.io/cookbook/v/poise-archive.svg)](https://supermarket.chef.io/cookbooks/poise-archive)\n[![Coverage](https://img.shields.io/codecov/c/github/poise/poise-archive.svg)](https://codecov.io/github/poise/poise-archive)\n[![Gemnasium](https://img.shields.io/gemnasium/poise/poise-archive.svg)](https://gemnasium.com/poise/poise-archive)\n[![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)\n\nA [Chef](https://www.chef.io/) cookbook to unpack file archives.\n\nIt supports `.tar`, `.tar.gz`, `.tar.bz2`, and `.zip` archive files.\n\n## Quick Start\n\nTo download an unpack and archive:\n\n```ruby\npoise_archive 'https://example.com/myapp.tgz' do\n destination '/opt/myapp'\nend\n```\n\n## Requirements\n\nChef 12.1 or newer is required.\n\n## Platforms\n\nThis cookbook supports all platforms (including Windows) but some Unix platforms\n(Solaris, AIX) may see very slow tar file unpacking when using the pure-Ruby fallback\nimplementation.\n\n## Resources\n\n### `poise_archive`\n\nThe `poise_archive` resource unpacks file archives.\n\n```ruby\npoise_archive '/tmp/myapp-1.2.0.tar' do\n destination '/srv/myapp-1.2.0'\nend\n```\n\nA URL can also be passed as the source path, optionally with extra properties to\nbe merged with `source_properties`.\n\n```ruby\npoise_archive 'http://example.com/myapp-1.2.0.zip' do\n destination '/srv/myapp-1.2.0'\nend\n\npoise_archive ['http://example.com/myapp-1.2.0.zip', {headers: {'Authentication' => '...'}}] do\n destination '/srv/myapp-1.2.0'\nend\n```\n\n#### Actions\n\n* `:unpack` Unpack the archive. *(default)*\n\n#### Properties\n\n* `path` Path to the archive. If relative, it is taken as a file inside\n `Chef::Config[:file_cache_path]`. If a URL, it is downloaded to a cache file\n first. *(name attribute)*\n* `destination` Path to unpack the archive to. If not specified, the path of\n the archive without the file extension is used. Required when unpacking from\n a URL. *(default: auto)*\n* `group` Group to run the unpack as.\n* `keep_existing` Keep existing files in the destination directory when\n unpacking. *(default: false)*\n* `source_properties` Property key/value pairs to be applied to the\n `remote_file` file resource when downloading a URL. *(default: {retries: 5})*\n* `strip_components` Number of intermediary directories to skip when\n unpacking. Works like GNU tar's `--strip-components`. *(default: 1)*\n* `user` User to run the unpack as.\n\n## Sponsors\n\nDevelopment sponsored by [Bloomberg](http://www.bloomberg.com/company/technology/).\n\nThe Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/).\n\n## License\n\nCopyright 2016-2017, Noah Kantrowitz\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\nBZip2 implementation is based on RBzip2. Copyright Sebastian Staudt, Brian Lopez.\nRBzip2 code used under the terms of the new BSD license.\n","maintainer":"Noah Kantrowitz","maintainer_email":"noah@coderanger.net","license":"Apache 2.0","platforms":{},"dependencies":{"poise":"~> 2.6"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/poise/poise-archive","issues_url":"https://github.com/poise/poise-archive/issues","chef_version":"~> 12","ohai_version":{}} {"name":"poise-archive","version":"1.5.0","description":"A Chef cookbook for unpacking file archives like tar and zip.","long_description":"# Poise-Archive Cookbook\n\n[![Build Status](https://img.shields.io/travis/poise/poise-archive.svg)](https://travis-ci.org/poise/poise-archive)\n[![Gem Version](https://img.shields.io/gem/v/poise-archive.svg)](https://rubygems.org/gems/poise-archive)\n[![Cookbook Version](https://img.shields.io/cookbook/v/poise-archive.svg)](https://supermarket.chef.io/cookbooks/poise-archive)\n[![Coverage](https://img.shields.io/codecov/c/github/poise/poise-archive.svg)](https://codecov.io/github/poise/poise-archive)\n[![Gemnasium](https://img.shields.io/gemnasium/poise/poise-archive.svg)](https://gemnasium.com/poise/poise-archive)\n[![License](https://img.shields.io/badge/license-Apache_2-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)\n\nA [Chef](https://www.chef.io/) cookbook to unpack file archives.\n\nIt supports `.tar`, `.tar.gz`, `.tar.bz2`, and `.zip` archive files.\n\n## Quick Start\n\nTo download an unpack and archive:\n\n```ruby\npoise_archive 'https://example.com/myapp.tgz' do\n destination '/opt/myapp'\nend\n```\n\n## Requirements\n\nChef 12.1 or newer is required.\n\n## Platforms\n\nThis cookbook supports all platforms (including Windows) but some Unix platforms\n(Solaris, AIX) may see very slow tar file unpacking when using the pure-Ruby fallback\nimplementation.\n\n## Resources\n\n### `poise_archive`\n\nThe `poise_archive` resource unpacks file archives.\n\n```ruby\npoise_archive '/tmp/myapp-1.2.0.tar' do\n destination '/srv/myapp-1.2.0'\nend\n```\n\nA URL can also be passed as the source path, optionally with extra properties to\nbe merged with `source_properties`.\n\n```ruby\npoise_archive 'http://example.com/myapp-1.2.0.zip' do\n destination '/srv/myapp-1.2.0'\nend\n\npoise_archive ['http://example.com/myapp-1.2.0.zip', {headers: {'Authentication' => '...'}}] do\n destination '/srv/myapp-1.2.0'\nend\n```\n\n#### Actions\n\n* `:unpack` Unpack the archive. *(default)*\n\n#### Properties\n\n* `path` Path to the archive. If relative, it is taken as a file inside\n `Chef::Config[:file_cache_path]`. If a URL, it is downloaded to a cache file\n first. *(name attribute)*\n* `destination` Path to unpack the archive to. If not specified, the path of\n the archive without the file extension is used. Required when unpacking from\n a URL. *(default: auto)*\n* `group` Group to run the unpack as.\n* `keep_existing` Keep existing files in the destination directory when\n unpacking. *(default: false)*\n* `source_properties` Property key/value pairs to be applied to the\n `remote_file` file resource when downloading a URL. *(default: {retries: 5})*\n* `strip_components` Number of intermediary directories to skip when\n unpacking. Works like GNU tar's `--strip-components`. *(default: 1)*\n* `user` User to run the unpack as.\n\n## Sponsors\n\nDevelopment sponsored by [Bloomberg](http://www.bloomberg.com/company/technology/).\n\nThe Poise test server infrastructure is sponsored by [Rackspace](https://rackspace.com/).\n\n## License\n\nCopyright 2016-2017, Noah Kantrowitz\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\nBZip2 implementation is based on RBzip2. Copyright Sebastian Staudt, Brian Lopez.\nRBzip2 code used under the terms of the new BSD license.\n","maintainer":"Noah Kantrowitz","maintainer_email":"noah@coderanger.net","license":"Apache 2.0","platforms":{},"dependencies":{"poise":"~> 2.6"},"recommendations":{},"suggestions":{},"conflicting":{},"providing":{},"replacing":{},"attributes":{},"groupings":{},"recipes":{},"source_url":"https://github.com/poise/poise-archive","issues_url":"https://github.com/poise/poise-archive/issues","chef_version":[["< 14",">= 12.1"]],"ohai_version":[]}

View File

@ -1,5 +1,23 @@
# Poise-Service Changelog # Poise-Service Changelog
## v1.5.2
* Set `declared_type` on the mixin-created `poise_service` resource so it works
correctly with ChefSpec.
## v1.5.1
* Fix the `sysvinit` provider on Amazon Linux under Chef 13.
## v1.5.0
* Added `never_start` and `never_stop` provider options to prevent Chef from starting
or stopping a service.
* Automatically reload systemd when removing a service if auto_reload is enabled.
* Improved dummy provider, records process output to `/var/run/service_name.out`
and a `restart_delay` provider option to the dummy provider to wait between
stopping and starting.
## v1.4.2 ## v1.4.2
* Fix the `noterm` test service to work on Ruby 2.3. * Fix the `noterm` test service to work on Ruby 2.3.

View File

@ -256,6 +256,8 @@ process creating a PID file in the given path.
* `reload_signal` Override the service reload signal. * `reload_signal` Override the service reload signal.
* `stop_signal` Override the service stop signal. * `stop_signal` Override the service stop signal.
* `user` Override the service user. * `user` Override the service user.
* `never_start` Never try to start the service.
* `never_stop` Never try to stop the service.
* `never_restart` Never try to restart the service. * `never_restart` Never try to restart the service.
* `never_reload` Never try to reload the service. * `never_reload` Never try to reload the service.
* `script_path` Override the path to the generated service script. * `script_path` Override the path to the generated service script.
@ -294,6 +296,8 @@ default and will throw an error if a reload signal other than SIGHUP is used.
* `reload_signal` Override the service reload signal. * `reload_signal` Override the service reload signal.
* `stop_signal` Override the service stop signal. * `stop_signal` Override the service stop signal.
* `user` Override the service user. * `user` Override the service user.
* `never_start` Never try to start the service.
* `never_stop` Never try to stop the service.
* `never_restart` Never try to restart the service. * `never_restart` Never try to restart the service.
* `never_reload` Never try to reload the service. * `never_reload` Never try to reload the service.
@ -320,6 +324,8 @@ end
* `reload_signal` Override the service reload signal. * `reload_signal` Override the service reload signal.
* `stop_signal` Override the service stop signal. * `stop_signal` Override the service stop signal.
* `user` Override the service user. * `user` Override the service user.
* `never_start` Never try to start the service.
* `never_stop` Never try to stop the service.
* `never_restart` Never try to restart the service. * `never_restart` Never try to restart the service.
* `never_reload` Never try to reload the service. * `never_reload` Never try to reload the service.
* `auto_reload` Run `systemctl daemon-reload` after changes to the unit file. *(default: true)* * `auto_reload` Run `systemctl daemon-reload` after changes to the unit file. *(default: true)*
@ -343,6 +349,8 @@ as they are enabled.
#### Options #### Options
* `never_start` Never try to start the service.
* `never_stop` Never try to stop the service.
* `never_restart` Never try to restart the service. * `never_restart` Never try to restart the service.
* `never_reload` Never try to reload the service. * `never_reload` Never try to reload the service.
* `pid_file` Path to PID file that the service command will create. * `pid_file` Path to PID file that the service command will create.
@ -350,6 +358,32 @@ as they are enabled.
auto-generated hash based on the service name. If these collide, bad things auto-generated hash based on the service name. If these collide, bad things
happen. Don't do that. happen. Don't do that.
### `dummy`
The `dummy` provider supports launching services directly from Chef itself.
This is for testing purposes only and is entirely unsuitable for use in
production. This is mostly useful when used alongside kitchen-docker.
```ruby
poise_service 'myapp' do
provider :dummy
command 'myapp --serve'
end
```
The service information is written to `/var/run`. The PID file is `service_name.pid`,
the command output is `service_name.out`, and the service parameters are in
`service_name.json`.
#### Options
* `never_start` Never try to start the service.
* `never_stop` Never try to stop the service.
* `never_restart` Never try to restart the service.
* `never_reload` Never try to reload the service.
* `restart_delay` Number of seconds to wait between stop and start when
restarting. *(default: 1)*
## ServiceMixin ## ServiceMixin
For the common case of a resource (LWRP or plain Ruby) that roughly maps to For the common case of a resource (LWRP or plain Ruby) that roughly maps to

View File

@ -167,6 +167,7 @@ module PoiseService
def service_resource def service_resource
@service_resource ||= PoiseService::Resources::PoiseService::Resource.new(new_resource.name, run_context).tap do |r| @service_resource ||= PoiseService::Resources::PoiseService::Resource.new(new_resource.name, run_context).tap do |r|
# Set some defaults. # Set some defaults.
r.declared_type = :poise_service
r.enclosing_provider = self r.enclosing_provider = self
r.source_line = new_resource.source_line r.source_line = new_resource.source_line
r.service_name(new_resource.service_name) r.service_name(new_resource.service_name)

View File

@ -70,12 +70,14 @@ module PoiseService
end end
def action_start def action_start
return if options['never_start']
notify_if_service do notify_if_service do
service_resource.run_action(:start) service_resource.run_action(:start)
end end
end end
def action_stop def action_stop
return if options['never_stop']
notify_if_service do notify_if_service do
service_resource.run_action(:stop) service_resource.run_action(:stop)
end end
@ -139,6 +141,7 @@ module PoiseService
# restart actions. # restart actions.
def service_resource def service_resource
@service_resource ||= Chef::Resource::Service.new(new_resource.service_name, run_context).tap do |r| @service_resource ||= Chef::Resource::Service.new(new_resource.service_name, run_context).tap do |r|
r.declared_type = :service
r.enclosing_provider = self r.enclosing_provider = self
r.source_line = new_resource.source_line r.source_line = new_resource.source_line
r.supports(status: true, restart: true, reload: true) r.supports(status: true, restart: true, reload: true)

View File

@ -25,7 +25,16 @@ module PoiseService
class Dummy < Base class Dummy < Base
provides(:dummy) provides(:dummy)
# @api private
def self.default_inversion_options(node, resource)
super.merge({
# Time to wait between stop and start.
restart_delay: 1,
})
end
def action_start def action_start
return if options['never_start']
return if pid return if pid
Chef::Log.debug("[#{new_resource}] Starting #{new_resource.command}") Chef::Log.debug("[#{new_resource}] Starting #{new_resource.command}")
# Clear the pid file if it exists. # Clear the pid file if it exists.
@ -45,39 +54,62 @@ module PoiseService
end end
else else
# :nocov: # :nocov:
Chef::Log.debug("[#{new_resource}] Forked") begin
# First child, daemonize and go to town. This handles multi-fork, Chef::Log.debug("[#{new_resource}] Forked")
# setsid, and shutting down stdin/out/err. # First child, daemonize and go to town. This handles multi-fork,
Process.daemon(true) # setsid, and shutting down stdin/out/err.
Chef::Log.debug("[#{new_resource}] Daemonized") Process.daemon(true)
# Daemonized, set up process environment. Chef::Log.debug("[#{new_resource}] Daemonized")
Dir.chdir(new_resource.directory) # Daemonized, set up process environment.
Chef::Log.debug("[#{new_resource}] Directory changed to #{new_resource.directory}") Dir.chdir(new_resource.directory)
ENV['HOME'] = Dir.home(new_resource.user) Chef::Log.debug("[#{new_resource}] Directory changed to #{new_resource.directory}")
new_resource.environment.each do |key, val| ENV['HOME'] = Dir.home(new_resource.user)
ENV[key.to_s] = val.to_s new_resource.environment.each do |key, val|
ENV[key.to_s] = val.to_s
end
Chef::Log.debug("[#{new_resource}] Process environment configured")
# Make sure to open the output file and write the pid file before we
# drop privs.
output = ::File.open(output_file, 'ab')
IO.write(pid_file, Process.pid)
Chef::Log.debug("[#{new_resource}] PID #{Process.pid} written to #{pid_file}")
ent = Etc.getpwnam(new_resource.user)
if Process.euid != ent.uid || Process.egid != ent.gid
Process.initgroups(ent.name, ent.gid)
Process::GID.change_privilege(ent.gid) if Process.egid != ent.gid
Process::UID.change_privilege(ent.uid) if Process.euid != ent.uid
Chef::Log.debug("[#{new_resource}] Changed privs to #{new_resource.user} (#{ent.uid}:#{ent.gid})")
end
# Log the command. Happens before ouput redirect or this ends up in the file.
Chef::Log.debug("[#{new_resource}] Execing #{new_resource.command}")
# Set up output logging.
Chef::Log.debug("[#{new_resource}] Logging output to #{output_file}")
$stdout.reopen(output)
$stdout.sync = true
$stderr.reopen(output)
$stderr.sync = true
$stdout.write("#{Time.now} Starting #{new_resource.command}")
# Split the command so we don't get an extra sh -c.
Kernel.exec(*Shellwords.split(new_resource.command))
# Just in case, bail out.
$stdout.reopen(STDOUT)
$stderr.reopen(STDERR)
Chef::Log.debug("[#{new_resource}] Exec failed, bailing out.")
exit!
rescue Exception => e
# Welp, we tried.
$stdout.reopen(STDOUT)
$stderr.reopen(STDERR)
Chef::Log.error("[#{new_resource}] Error during process spawn: #{e}")
exit!
end end
Chef::Log.debug("[#{new_resource}] Process environment configured")
IO.write(pid_file, Process.pid)
Chef::Log.debug("[#{new_resource}] PID written to #{pid_file}")
ent = Etc.getpwnam(new_resource.user)
if Process.euid != ent.uid || Process.egid != ent.gid
Process.initgroups(ent.name, ent.gid)
Process::GID.change_privilege(ent.gid) if Process.egid != ent.gid
Process::UID.change_privilege(ent.uid) if Process.euid != ent.uid
end
Chef::Log.debug("[#{new_resource}] Changed privs to #{new_resource.user} (#{ent.uid}:#{ent.gid})")
# Split the command so we don't get an extra sh -c.
Chef::Log.debug("[#{new_resource}] Execing #{new_resource.command}")
Kernel.exec(*Shellwords.split(new_resource.command))
# Just in case, bail out.
exit!
# :nocov: # :nocov:
end end
Chef::Log.debug("[#{new_resource}] Started.") Chef::Log.debug("[#{new_resource}] Started.")
end end
def action_stop def action_stop
return if options['never_stop']
return unless pid return unless pid
Chef::Log.debug("[#{new_resource}] Stopping with #{new_resource.stop_signal}. Current PID is #{pid.inspect}.") Chef::Log.debug("[#{new_resource}] Stopping with #{new_resource.stop_signal}. Current PID is #{pid.inspect}.")
Process.kill(new_resource.stop_signal, pid) Process.kill(new_resource.stop_signal, pid)
@ -87,6 +119,8 @@ module PoiseService
def action_restart def action_restart
return if options['never_restart'] return if options['never_restart']
action_stop action_stop
# Give things a moment to stop before we try starting again.
sleep(options['restart_delay'])
action_start action_start
end end
@ -151,6 +185,11 @@ module PoiseService
"/var/run/#{new_resource.service_name}.pid" "/var/run/#{new_resource.service_name}.pid"
end end
# Path to the output file.
def output_file
"/var/run/#{new_resource.service_name}.out"
end
end end
end end
end end

View File

@ -27,8 +27,6 @@ module PoiseService
# @api private # @api private
def self.provides_auto?(node, resource) def self.provides_auto?(node, resource)
# Don't allow systemd under docker, it won't work in most cases.
return false if node['virtualization'] && %w{docker lxc}.include?(node['virtualization']['system'])
service_resource_hints.include?(:systemd) service_resource_hints.include?(:systemd)
end end
@ -75,8 +73,10 @@ module PoiseService
end end
def destroy_service def destroy_service
reloader = systemctl_daemon_reload
file "/etc/systemd/system/#{new_resource.service_name}.service" do file "/etc/systemd/system/#{new_resource.service_name}.service" do
action :delete action :delete
notifies :run, reloader, :immediately if options['auto_reload']
end end
end end

View File

@ -37,7 +37,7 @@ module PoiseService
r.provider(case node['platform_family'] r.provider(case node['platform_family']
when 'debian' when 'debian'
Chef::Provider::Service::Debian Chef::Provider::Service::Debian
when 'rhel' when 'rhel', 'amazon'
Chef::Provider::Service::Redhat Chef::Provider::Service::Redhat
else else
# Better than nothing I guess? Will fail on enable I think. # Better than nothing I guess? Will fail on enable I think.

View File

@ -30,11 +30,17 @@ module PoiseService
provides(:upstart) provides(:upstart)
def self.provides_auto?(node, resource) def self.provides_auto?(node, resource)
# Don't allow upstart under docker, it won't work.
return false if node['virtualization'] && %w{docker lxc}.include?(node['virtualization']['system'])
service_resource_hints.include?(:upstart) service_resource_hints.include?(:upstart)
end end
# @api private
def self.default_inversion_options(node, resource)
super.merge({
# Time to wait between stop and start.
restart_delay: 1,
})
end
# True restart in Upstart preserves the original config data, we want the # True restart in Upstart preserves the original config data, we want the
# more obvious behavior like everything else in the world that restart # more obvious behavior like everything else in the world that restart
# would re-read the updated config file. Use stop+start to get this # would re-read the updated config file. Use stop+start to get this
@ -42,6 +48,8 @@ module PoiseService
def action_restart def action_restart
return if options['never_restart'] return if options['never_restart']
action_stop action_stop
# Give things a moment to stop before we try starting again.
sleep(options['restart_delay'])
action_start action_start
end end

View File

@ -16,5 +16,5 @@
module PoiseService module PoiseService
VERSION = '1.4.2' VERSION = '1.5.2'
end end

File diff suppressed because one or more lines are too long