From 153b12ca026c7d3a9878cb3993af84ea2d58d0a2 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Tue, 6 Mar 2018 13:30:25 +0100 Subject: [PATCH] ferm::conf - merge with tor version --- modules/ferm/manifests/conf.pp | 40 +++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/modules/ferm/manifests/conf.pp b/modules/ferm/manifests/conf.pp index 0dffa773d..602b74ba4 100644 --- a/modules/ferm/manifests/conf.pp +++ b/modules/ferm/manifests/conf.pp @@ -1,29 +1,39 @@ -define ferm::conf ($content=undef, $source=undef, $ensure=present) { - - include ferm - +# +define ferm::conf ( + $source=undef, + $content=undef, + $ensure=present, + $prio="xx-10", +) { case $ensure { - present,absent: {} - default: { fail ( "Invald ensure `${ensure}' for ${name}" ) } + present: { + if ! ($source or $content) { + fail ( "No configuration found for ${name}" ) + } + } + absent: {} + default: { fail ( "Unknown ensure value: '$ensure'" ) } } if ($source and $content) { fail ( "Can't define both source and content for ${name}" ) } - $fname = "/etc/ferm/conf.d/${name}.conf" + $fname = "/etc/ferm/conf.d/${prio}_${name}.conf" - if $source { + if $content { file { $fname: - ensure => $ensure, - source => $source, - notify => Service['ferm'] + ensure => $ensure, + mode => '0400', + content => $content, + notify => Exec["ferm restart"], } - } elsif $content { + } else { file { $fname: - ensure => $ensure, - content => $content, - notify => Service['ferm'] + ensure => $ensure, + mode => '0400', + source => $source, + notify => Exec["ferm restart"], } } } -- 2.20.1