Skip to content

Commit

Permalink
Enclose the 'include systemd' in the module
Browse files Browse the repository at this point in the history
When using a different module to call the systemd
class and also using systemd::unit_file you get a
duplicate resource. By this 'if !defined' this is
solved. Issue #505
  • Loading branch information
ralfbosz committed Jan 7, 2025
1 parent 58f0075 commit b682c6d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion manifests/daemon_reload.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
Boolean $enable = true,
Optional[String[1]] $user = undef,
) {
include systemd
if !defined(Class['systemd']) {
include systemd
}

if $enable {
if $user {
Expand Down
4 changes: 3 additions & 1 deletion manifests/dropin_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
Boolean $notify_service = true,
Boolean $daemon_reload = true,
) {
include systemd
if !defined(Class['systemd']) {
include systemd
}

if $target {
$_ensure = 'link'
Expand Down
4 changes: 3 additions & 1 deletion manifests/network.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
Boolean $show_diff = true,
Boolean $restart_service = true,
) {
include systemd
if !defined(Class['systemd']) {
include systemd
}

if $restart_service and $systemd::manage_networkd and $facts['systemd_internal_services'] and $facts['systemd_internal_services']['systemd-networkd.service'] {
$notify = Service['systemd-networkd']
Expand Down
4 changes: 3 additions & 1 deletion manifests/service_limits.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
fail('The restart_service parameter is deprecated and only false is a valid value')
}

include systemd
if !defined(Class['systemd']) {
include systemd
}

if $name !~ Pattern['^.+\.(service|socket|mount|swap)$'] {
fail('$name must match Pattern["^.+\.(service|socket|mount|swap)$"]')
Expand Down
4 changes: 3 additions & 1 deletion manifests/unit_file.pp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@
Boolean $daemon_reload = true,
Boolean $service_restart = true,
) {
include systemd
if !defined(Class['systemd']) {
include systemd
}

assert_type(Systemd::Unit, $name)

Expand Down

0 comments on commit b682c6d

Please sign in to comment.