From e7013011290a10fe29dfe5816e2263c399c4e644 Mon Sep 17 00:00:00 2001 From: Mikhail Stolyarov Date: Mon, 19 Aug 2024 14:52:04 +0300 Subject: [PATCH] [service] More precise service control --- manifests/init.pp | 16 ++++++++++------ manifests/service.pp | 8 +++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 15726fa..a8e02ce 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,10 +1,12 @@ class dnsmasq ( - Hash $configs_hash = {}, - Hash $hosts_hash = {}, - Hash $dhcp_hosts_hash = {}, - String $package_ensure = 'installed', - Boolean $service_control = true, - Boolean $purge_config_dir = false, + Hash $configs_hash = {}, + Hash $hosts_hash = {}, + Hash $dhcp_hosts_hash = {}, + String $package_ensure = 'installed', + Boolean $service_control = true, + Enum['running', 'stopped'] $service_ensure = 'running', + Boolean $service_enable = true, + Boolean $purge_config_dir = false, ) { include dnsmasq::params @@ -14,6 +16,8 @@ class { 'dnsmasq::service': service_control => $service_control, + service_ensure => $service_ensure, + service_enable => $server_enable, subscribe => Class['dnsmasq::install', 'dnsmasq::config'], } diff --git a/manifests/service.pp b/manifests/service.pp index ea62e15..2baa741 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,5 +1,7 @@ class dnsmasq::service ( - Variant[String, Boolean] $service_control = $dnsmasq::params::service_control, + Variant[String, Boolean] $service_control = $dnsmasq::params::service_control, + Enum['running', 'stopped'] $service_ensure = 'running', + Boolean $service_enable = true, ) { # validate type and convert string to boolean if necessary if $service_control =~ String { @@ -9,8 +11,8 @@ } if $service_control_real == true { service { $dnsmasq::params::service_name: - ensure => 'running', - enable => true, + ensure => $service_ensure, + enable => $service_enable, hasrestart => true, hasstatus => true, }