Page MenuHomePhabricator

rspec-puppet fails with Could not find the daemon directory (tested [/etc/sv,/var/lib/service])
Closed, ResolvedPublic

Description

Sometime the operations/puppet.git rspec tests fail with:

Could not find the daemon directory (tested [/etc/sv,/var/lib/service])

Reproduction

bundle install
bundle exec rake global:spec:install_server

The root cause is that puppet 4.8.2 does not support Debian 9 (Stretch) and fails to set systemd as the default init system. That worked fine with rspec-puppet 2.6.3 but 2.6.4 slightly changed how it confines facts ( https://github.com/rodjek/rspec-puppet/commit/308d0166cbd9dc75f6535ee1d0cf09c781fbc0b2 ). See https://github.com/rodjek/rspec-puppet/issues/629 which has:

When bumping rspec-puppet 2.6.3 to 2.6.4 I have been blessed with:

Warning: Found multiple default providers for service: runit, debian, redhat; using runit
     RuntimeError:
       Could not find the daemon directory (tested [/etc/sv,/var/lib/service])

That is with puppet 4.8.2 on a Debian Stretch (version 9).

Based on Puppet lib/puppet/provider/service/*.rb it does not seem to recognize the default service provider for Stretch:

lib/puppet/provider/service/systemd.rb

defaultfor :operatingsystem => :debian, :operatingsystemmajrelease => "8"
defaultfor :operatingsystem => :ubuntu, :operatingsystemmajrelease => ["15.04","15.10","16.04","16.10"]

We had that fixed previously by using https://github.com/mcanevet/rspec-puppet-facts . An example for a puppet repo https://github.com/wikimedia/integration-config/commit/27bed685c7e3358a7dd3a28d2b16beafef9d34dd

Event Timeline

Change 458495 had a related patch set uploaded (by Hashar; owner: Giuseppe Lavagetto):
[operations/puppet@production] service: fix spec for debian 9+

https://gerrit.wikimedia.org/r/458495

Change 458495 merged by Giuseppe Lavagetto:
[operations/puppet@production] service: fix spec for debian 9+

https://gerrit.wikimedia.org/r/458495

Dzahn triaged this task as Medium priority.Oct 13 2018, 1:43 AM
hashar claimed this task.

When someone encounters the issue, the module spec_helper.rb should:

require_relative '../../../rake_modules/fix_service_provider'

Which has:

# Force usage of the systemd provider by overriding the stupid defaults
# set by puppetlabs. This is the same thing that the debian package does,
# please see https://salsa.debian.org/puppet-team/puppet/commit/428f6e560dea3cab2f0be39d51806c321bbf6e61
Puppet::Type.type(:service).provide(:systemd).class_eval do
  defaultfor :operatingsystem => :debian
end

Which makes Puppet to use the proper provider, specially on Stretch or later since Puppet 4.8 from rubygems does not support Stretch or later and default to someother system provider.