Skip to content

Commit

Permalink
Merge pull request #264 from bastelfreak/removeparams
Browse files Browse the repository at this point in the history
systemd::unit_file: remove hasrestart/hasstatus params
  • Loading branch information
jhoblitt authored Jan 26, 2023
2 parents 91af2ff + d0e41a3 commit 9c33b95
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 106 deletions.
28 changes: 5 additions & 23 deletions manifests/unit_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@
# @param restart
# Specify a restart command manually. If left unspecified, a standard Puppet service restart happens.
#
# @param hasrestart
# maps to the same param on the service resource. Optional in the module because it's optional in the service resource type. This param is deprecated. Set it via $service_parameters.
#
# @param hasstatus
# maps to the same param on the service resource. true in the module because it's true in the service resource type. This param is deprecated. Set it via $service_parameters.
#
# @param selinux_ignore_defaults
# maps to the same param on the file resource for the unit. false in the module because it's false in the file resource type
#
Expand Down Expand Up @@ -84,8 +78,6 @@
Optional[Variant[Boolean, Enum['mask']]] $enable = undef,
Optional[Boolean] $active = undef,
Optional[String] $restart = undef,
Optional[Boolean] $hasrestart = undef,
Optional[Boolean] $hasstatus = undef,
Boolean $selinux_ignore_defaults = false,
Hash[String[1], Any] $service_parameters = {},
Boolean $daemon_reload = true
Expand All @@ -94,14 +86,6 @@

assert_type(Systemd::Unit, $name)

if $hasrestart =~ NotUndef {
deprecation("systemd::unit_file - ${title}", 'hasrestart is deprecated and will be removed in Version 4 of the module')
}

if $hasstatus =~ NotUndef {
deprecation("systemd::unit_file - ${title}", 'hasstatus is deprecated and will be removed in Version 4 of the module')
}

if $enable == 'mask' {
$_target = '/dev/null'
} else {
Expand Down Expand Up @@ -137,13 +121,11 @@

if $enable != undef or $active != undef {
service { $name:
ensure => $active,
enable => $enable,
restart => $restart,
provider => 'systemd',
hasrestart => $hasrestart,
hasstatus => $hasstatus,
* => $service_parameters,
ensure => $active,
enable => $enable,
restart => $restart,
provider => 'systemd',
* => $service_parameters,
}

if $ensure == 'absent' {
Expand Down
83 changes: 0 additions & 83 deletions spec/defines/unit_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,89 +128,6 @@
end
end

context 'with enable => true and active => true and service_parameters and duplicate param' do
let(:params) do
super().merge(
enable: true,
active: true,
hasrestart: true,
service_parameters: {
flags: '--awesome',
timeout: 1337,
hasrestart: false
}
)
end

it { is_expected.not_to compile }
end

context 'hasrestart => true' do
let(:params) do
super().merge(
enable: true,
active: true,
hasrestart: true
)
end

it { is_expected.to compile.with_all_deps }

it do
expect(subject).to contain_service('test.service').
with_ensure(true).
with_enable(true).
with_provider('systemd').
without_hasstatus.
with_hasrestart(true).
that_subscribes_to("File[/etc/systemd/system/#{title}]")
end
end

context 'hasrestart => false' do
let(:params) do
super().merge(
enable: true,
active: true,
hasrestart: false
)
end

it { is_expected.to compile.with_all_deps }

it do
expect(subject).to contain_service('test.service').
with_ensure(true).
with_enable(true).
with_provider('systemd').
without_hasstatus.
with_hasrestart(false).
that_subscribes_to("File[/etc/systemd/system/#{title}]")
end
end

context 'hasstatus => false' do
let(:params) do
super().merge(
enable: true,
active: true,
hasstatus: false
)
end

it { is_expected.to compile.with_all_deps }

it do
expect(subject).to contain_service('test.service').
with_ensure(true).
with_enable(true).
with_provider('systemd').
with_hasstatus(false).
without_hasrestart.
that_subscribes_to("File[/etc/systemd/system/#{title}]")
end
end

context 'ensure => absent' do
let(:params) { super().merge(ensure: 'absent') }

Expand Down

0 comments on commit 9c33b95

Please sign in to comment.