From 28b256e278bcb6d553c656071307f0516cb0fb48 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 8 Jan 2010 00:43:07 +0100 Subject: make it possible to set a webrepo to absent --- manifests/web/repo.pp | 27 +++++++++++++++++++-------- manifests/web/repo/lighttpd.pp | 21 +++++++++++++++------ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/manifests/web/repo.pp b/manifests/web/repo.pp index def9f62..ce6ab15 100644 --- a/manifests/web/repo.pp +++ b/manifests/web/repo.pp @@ -2,6 +2,7 @@ # projectroot: where the git repos are listened # projects_list: which repos to export define git::web::repo( + $ensure = 'present', $projectroot, $projects_list, $sitename='absent' @@ -13,19 +14,29 @@ define git::web::repo( default: { $gitweb_sitename = $sitename } } $gitweb_config = "/etc/gitweb.d/${name}.conf" - file{"${gitweb_config}": + file{"${gitweb_config}": } + if $ensure == 'present' { + File["${gitweb_config}"]{ content => template("git/web/config") + } + } else { + File["${gitweb_config}"]{ + ensure => absent, + } } case $gitweb_webserver { 'lighttpd': { - git::web::repo::lighttpd{$name: - gitweb_url => $gitweb_url, - gitweb_config => $gitweb_config, - } + git::web::repo::lighttpd{$name: + ensure => $ensure, + gitweb_url => $gitweb_url, + gitweb_config => $gitweb_config, + } } 'apache': { - apache::vhost::gitweb{$gitweb_url: } - } - default: { fail("no supported \$gitweb_webserver defined on ${fqdn}, so can't do git::web::repo: ${name}") } + apache::vhost::gitweb{$gitweb_url: + ensure => $ensure, + } + } + default: { fail("no supported \$gitweb_webserver defined on ${fqdn}, so can't do git::web::repo: ${name}") } } } diff --git a/manifests/web/repo/lighttpd.pp b/manifests/web/repo/lighttpd.pp index adc90e7..f740290 100644 --- a/manifests/web/repo/lighttpd.pp +++ b/manifests/web/repo/lighttpd.pp @@ -1,17 +1,26 @@ define git::web::repo::lighttpd( + ensure = 'present', $gitweb_url, $gitweb_config ){ + file{"/etc/lighttpd/gitweb.d/${name}.conf": } + if $ensure == 'present' { include git::web::lighttpd - file{"/etc/lighttpd/gitweb.d/${name}.conf": + File["/etc/lighttpd/gitweb.d/${name}.conf"]{ content => template("git/web/lighttpd"), notify => Service['lighttpd'], owner => root, group => 0, mode => 0644; } - line{"add_include_of_gitwebrepo_${name}": - line => "include \"gitweb.d/${name}.conf\"", - file => "/etc/lighttpd/lighttpd-gitweb.conf", - require => File['/etc/lighttpd/lighttpd-gitweb.conf'], - notify => Service['lighttpd'], + } else { + File["/etc/lighttpd/gitweb.d/${name}.conf"]{ + ensure => $ensure, } + } + line{"add_include_of_gitwebrepo_${name}": + ensure => $ensure, + line => "include \"gitweb.d/${name}.conf\"", + file => "/etc/lighttpd/lighttpd-gitweb.conf", + require => File['/etc/lighttpd/lighttpd-gitweb.conf'], + notify => Service['lighttpd'], + } } -- cgit v1.2.3