From 7aa7af250724ec62a3d4c2c107be9fb6da8385ee Mon Sep 17 00:00:00 2001 From: Ralf Bosz Date: Tue, 7 Jan 2025 15:02:43 +0100 Subject: [PATCH] Enclose the 'include systemd' in the module 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 --- manifests/daemon_reload.pp | 4 +++- manifests/dropin_file.pp | 4 +++- manifests/network.pp | 4 +++- manifests/service_limits.pp | 4 +++- manifests/unit_file.pp | 6 ++++-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/manifests/daemon_reload.pp b/manifests/daemon_reload.pp index 6acbb7f4..8ca4a20a 100644 --- a/manifests/daemon_reload.pp +++ b/manifests/daemon_reload.pp @@ -31,7 +31,9 @@ Boolean $enable = true, Optional[String[1]] $user = undef, ) { - include systemd + if !defined(Class['systemd']) { + include systemd + } if $enable { if $user { diff --git a/manifests/dropin_file.pp b/manifests/dropin_file.pp index 6b685f22..3e97a234 100644 --- a/manifests/dropin_file.pp +++ b/manifests/dropin_file.pp @@ -35,7 +35,9 @@ Boolean $notify_service = true, Boolean $daemon_reload = true, ) { - include systemd + if !defined(Class['systemd']) { + include systemd + } if $target { $_ensure = 'link' diff --git a/manifests/network.pp b/manifests/network.pp index bf63e69e..4a9756f4 100644 --- a/manifests/network.pp +++ b/manifests/network.pp @@ -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'] diff --git a/manifests/service_limits.pp b/manifests/service_limits.pp index ca07ad22..46c34152 100644 --- a/manifests/service_limits.pp +++ b/manifests/service_limits.pp @@ -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)$"]') diff --git a/manifests/unit_file.pp b/manifests/unit_file.pp index 237e27a9..a47f2ffd 100644 --- a/manifests/unit_file.pp +++ b/manifests/unit_file.pp @@ -86,8 +86,10 @@ Boolean $daemon_reload = true, Boolean $service_restart = true, ) { - include systemd - + if !defined(Class['systemd']) { + include systemd + } + assert_type(Systemd::Unit, $name) if $enable == 'mask' {