Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch service to default to systemd on Debian 9 #720

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/rspec-puppet/monkey_patches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,18 @@ def manages_symlinks?
end
end

# Puppet 4.8 systemd provider does not recognize Debian 9 (Stretch). It fall
# back to runit which causes:
# Could not find the daemon directory (tested [/etc/sv,/var/lib/service])
# The Debian package is patched, but the gem 4.8.2 is not.
# Support has been added in Puppet 4.10.0:
# https://github.com/puppetlabs/puppet/commit/d5a69fb57c15683873b422cb5e17ef06ca13cea5
if Puppet::Util::Package.versioncmp(Puppet.version, '4.8.0') >= 0 && Puppet::Util::Package.versioncmp(Puppet.version, '4.10.0') < 0
Puppet::Type.type(:service).provide(:systemd).instance_eval do
defaultfor :operatingsystem => :debian

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition is incorrect, as it will make tests for Debian < 8.0 fail or be inaccurate (those systems don't use systemd).

Also, the condition set in puppet 4.10.x is still wrong and overridden in the debian pacakges to this day.

The correct condition would probably be:

  • Monkey-patch all versions that include a systemd provider and offer the defaultfor method for providers
  • Add a specific defaultfor to the "debian" provider for debian versions up to 7 (you can limit yourself to 5,6,7)
  • Add this defaultfor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And on further discussion, @lavagetto pointed that the patch modifies the behavior of the puppet interpreter. That could potentially hide an issue when running puppet from Gem, but I guess everyone just use the patched up puppet debian package.

end
end

# Prevent Puppet from requiring 'puppet/util/windows' if we're pretending to be
# windows, otherwise it will require other libraries that probably won't be
# available on non-windows hosts.
Expand Down
7 changes: 7 additions & 0 deletions spec/classes/test_multi_os.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,12 @@
it 'sets the provider of the File resource to :posix' do
catalogue.resource('file', '/test').to_ral.provider.class.name.should eq(:posix)
end

describe "service resource" do
let (:pre_condition) { 'service { "foo": }' }
it 'sets provider to systemd' do
catalogue.resource('service', 'foo').to_ral.provider.class.name.should eq(:systemd)
end
end
end
end