Skip to content

Commit

Permalink
Support camptocamp/systemd 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ekohl committed May 26, 2021
1 parent 7c07b93 commit 446d8ab
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 1 addition & 3 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ fixtures:
repo: 'https://github.com/puppetlabs/puppetlabs-selinux_core'
puppet_version: '>= 6.0.0'
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib'
systemd:
repo: 'https://github.com/camptocamp/puppet-systemd'
ref: '2.12.0'
systemd: 'https://github.com/camptocamp/puppet-systemd'
16 changes: 14 additions & 2 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,23 @@
content => template('pulpcore/[email protected]'),
}

# In camptocamp/systemd 3.0.0 support for Puppet < 6.1.0 was dropped.
# This means there is no single daemon-reload class anymore. This also means
# there is no more relation that ensures all services are loaded prior to running them.
$metadata = load_module_metadata('systemd')
if SemVer($metadata['version']) >= SemVer('3.0.0') {
Systemd::Unit_file['pulpcore-api.socket'] -> Systemd::Unit_file['pulpcore-api.service']
Systemd::Unit_file['pulpcore-content.socket'] -> Systemd::Unit_file['pulpcore-content.service']
$reload_require = undef
} else {
$reload_require = Class['systemd::systemctl::daemon_reload']
}

Integer[1, $pulpcore::worker_count].each |$n| {
service { "pulpcore-worker@${n}.service":
ensure => $pulpcore::service_ensure,
enable => $pulpcore::service_enable,
require => Class['systemd::systemctl::daemon_reload'],
require => $reload_require,
subscribe => Systemd::Unit_file['[email protected]'],
}
}
Expand All @@ -53,7 +65,7 @@
service { $worker:
ensure => false,
enable => false,
require => [Systemd::Unit_file['[email protected]'], Class['systemd::systemctl::daemon_reload']],
require => [Systemd::Unit_file['[email protected]'], $reload_require],
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
{
"name": "camptocamp/systemd",
"version_requirement": ">= 2.2.0 < 3.0.0"
"version_requirement": ">= 2.2.0 < 4.0.0"
},
{
"name": "puppet/extlib",
Expand Down
4 changes: 4 additions & 0 deletions spec/classes/pulpcore_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@

it 'configures services' do
is_expected.to contain_class('pulpcore::service')
is_expected.to contain_systemd__unit_file('pulpcore-api.socket').that_comes_before('Systemd::Unit_file[pulpcore-api.service]')
is_expected.to contain_systemd__unit_file('pulpcore-api.service').that_requires('Systemd::Unit_file[pulpcore-api.socket]')
is_expected.to contain_systemd__unit_file('pulpcore-content.socket').that_comes_before('Systemd::Unit_file[pulpcore-content.service]')
is_expected.to contain_systemd__unit_file('pulpcore-content.service').that_requires('Systemd::Unit_file[pulpcore-content.socket]')
is_expected.to contain_systemd__unit_file('pulpcore-resource-manager.service')
is_expected.to contain_systemd__unit_file('[email protected]')
is_expected.to contain_service("[email protected]").with_ensure(true)
Expand Down

0 comments on commit 446d8ab

Please sign in to comment.