From 04c874dd3679b846e6ea9997c0cc33f542444ad2 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 7 Mar 2009 13:11:06 +0000 Subject: we can now remove an apache vhost --- manifests/defines/configuration.pp | 42 +++++++----- manifests/defines/htpasswd.pp | 2 + manifests/defines/modules.pp | 4 ++ manifests/defines/vhost_files.pp | 57 ++++++++++++++++ manifests/defines/vhost_varieties.pp | 126 ++++++++++++++++------------------- 5 files changed, 145 insertions(+), 86 deletions(-) (limited to 'manifests') diff --git a/manifests/defines/configuration.pp b/manifests/defines/configuration.pp index f6bae30..5137fe5 100644 --- a/manifests/defines/configuration.pp +++ b/manifests/defines/configuration.pp @@ -4,6 +4,7 @@ # deploy apache (.conf) configuration file (non-vhost) define apache::config::file( + $ensure = present, $source = 'absent', $content = 'absent', $destination = 'absent' @@ -20,6 +21,7 @@ define apache::config::file( default => $destination } file{"apache_${name}": + ensure => $ensure, path => $real_destination, notify => Service[apache], owner => root, group => 0, mode => 0644; @@ -108,21 +110,29 @@ define apache::vhost::webdir( } default: { $real_documentroot_group = $documentroot_group } } - file{"$real_path": - ensure => directory, - owner => $owner, group => $group, mode => '0755'; - } - case $documentroot_recurse { - '': { $real_documentroot_recurse = false } - default: { $real_documentroot_recurse = $documentroot_recurse } - } - file{"$documentroot": - ensure => directory, - owner => $real_documentroot_owner, group => $real_documentroot_group, mode => $documentroot_mode, - recurse => $real_documentroot_recurse; - } - file{$logdir: - ensure => directory, - owner => $real_documentroot_owner, group => $group, mode => 750; + case $ensure { + absent: { + file{[ "$real_path", "$documentroot", "$logdir" ]: + ensure => absent, + purge => true, + recurse => true, + force => true, + } + } + default: { + file{"$real_path": + ensure => directory, + owner => $owner, group => $group, mode => '0755'; + } + file{"$documentroot": + ensure => directory, + recurse => $documentroot_recurse, + owner => $real_documentroot_owner, group => $real_documentroot_group, mode => $documentroot_mode; + } + file{"$logdir": + ensure => directory, + owner => $real_documentroot_owner, group => $group, mode => 750; + } + } } } diff --git a/manifests/defines/htpasswd.pp b/manifests/defines/htpasswd.pp index 74da6fd..2994f81 100644 --- a/manifests/defines/htpasswd.pp +++ b/manifests/defines/htpasswd.pp @@ -2,6 +2,7 @@ # ToDo: This should be rewritten as native type define apache::htpasswd_user( + $ensure = present, $site = 'absent', $username = 'absent', $password, @@ -28,6 +29,7 @@ define apache::htpasswd_user( } line{"htpasswd_for_${real_site}": + ensure => $ensure, file => $real_path, line => "${username}:${real_password}", } diff --git a/manifests/defines/modules.pp b/manifests/defines/modules.pp index 8e8ceff..b0f5941 100644 --- a/manifests/defines/modules.pp +++ b/manifests/defines/modules.pp @@ -3,6 +3,7 @@ ### manage apache modules define apache::centos::module( + $ensure = present, $source = '', $destination = '' ){ @@ -22,6 +23,7 @@ define apache::centos::module( default => "puppet://$server/$source", } file{"modules_${name}.conf": + ensure => $ensure, path => $real_destination, source => $real_source, require => [ File[modules_dir], Package[apache] ], @@ -31,6 +33,7 @@ define apache::centos::module( } define apache::gentoo::module( + $ensure = present, $source = '', $destination = '' ){ @@ -50,6 +53,7 @@ define apache::gentoo::module( default => "puppet://$server/$source", } file{"modules_${name}.conf": + ensure => $ensure, path => $real_destination, source => $real_source, require => [ File[modules_dir], Package[apache] ], diff --git a/manifests/defines/vhost_files.pp b/manifests/defines/vhost_files.pp index e312df9..3361eee 100644 --- a/manifests/defines/vhost_files.pp +++ b/manifests/defines/vhost_files.pp @@ -12,6 +12,7 @@ # - file: deploy a vhost file (apache::vhost::file will be called directly) # define apache::vhost( + $ensure = present, $path = 'absent', $template_mode = 'static', $vhost_mode = 'template', @@ -41,6 +42,7 @@ define apache::vhost( case $vhost_mode { 'file': { apache::vhost::file{$name: + ensure => $ensure, vhost_source => $vhost_source, vhost_destination => $vhost_destination, do_includes => $do_includes, @@ -50,6 +52,7 @@ define apache::vhost( } 'template': { apache::vhost::template{$name: + ensure => $ensure, path => $path, domain => $domain, domainalias => $domainalias, @@ -86,6 +89,7 @@ define apache::vhost( # - else: path to deploy # define apache::vhost::file( + $ensure = present, $vhost_source = 'absent', $vhost_destination = 'absent', $content = 'absent', @@ -106,6 +110,7 @@ define apache::vhost::file( default => $vhost_destination, } file{"$name.conf": + ensure => $ensure, path => $real_vhost_destination, require => File[vhosts_dir], notify => Service[apache], @@ -156,6 +161,7 @@ define apache::vhost::file( default: { $real_htpasswd_path = $htpasswd_path } } file{$real_htpasswd_path: + ensure => $ensure, source => [ "puppet://$server/files/apache/htpasswds/$fqdn/$name", "puppet://$server/files/apache/htpasswds/$apache_cluster_node/$name", "puppet://$server/files/apache/htpasswds/$name" ], @@ -182,6 +188,7 @@ define apache::vhost::file( # - force: enable ssl and redirect non-ssl to ssl # define apache::vhost::template( + $ensure = present, $path = 'absent', $domain = 'absent', $domainalias = 'absent', @@ -245,6 +252,7 @@ define apache::vhost::template( } } apache::vhost::file{$name: + ensure => $ensure, content => template("apache/vhosts/$template_mode/$operatingsystem.erb"), do_includes => $do_includes, htpasswd_file => $htpasswd_file, @@ -294,3 +302,52 @@ define apache::vhost::file::documentrootdir( } + +define apache::vhost::phpdirs( + $ensure = present, + $upload_tmp_dir = 'absent', + $session_save_path = 'absent', + $documentroot_owner = apache, + $documentroot_group = 0, + $documentroot_mode = 0750, + $run_mode = 'normal', + $run_uid = 'absent' +){ + # php upload_tmp_dir + case $upload_tmp_dir { + 'absent': { + include apache::defaultphpdirs + $real_upload_tmp_dir = "/var/www/upload_tmp_dir/$name" + } + default: { $real_upload_tmp_dir = $upload_tmp_dir } + } + # php session_save_path + case $session_save_path { + 'absent': { + include apache::defaultphpdirs + $real_session_save_path = "/var/www/session.save_path/$name" + } + default: { $real_session_save_path = $session_save_path } + } + + case $ensure { + absent: { + file{[$real_upload_tmp_dir, $real_session_save_path ]: + ensure => absent, + purge => true, + force => true, + recurse => true, + } + } + default: { + file{[$real_upload_tmp_dir, $real_session_save_path ]: + ensure => directory, + owner => $run_mode ? { + 'itk' => $run_uid, + default => $documentroot_owner + }, + group => $documentroot_group, mode => $documentroot_mode; + } + } + } +} diff --git a/manifests/defines/vhost_varieties.pp b/manifests/defines/vhost_varieties.pp index e5e180b..a75f627 100644 --- a/manifests/defines/vhost_varieties.pp +++ b/manifests/defines/vhost_varieties.pp @@ -14,6 +14,7 @@ # - file: deploy a vhost file (apache::vhost::file will be called directly) # define apache::vhost::static( + $ensure = present, $domain = 'absent', $domainalias = 'absent', $path = 'absent', @@ -36,6 +37,7 @@ define apache::vhost::static( ){ # create webdir apache::vhost::webdir{$name: + ensure => $ensure, path => $path, owner => $owner, group => $group, @@ -46,6 +48,7 @@ define apache::vhost::static( # create vhost configuration file apache::vhost{$name: + ensure => $ensure, path => $path, template_mode => 'static', vhost_mode => $vhost_mode, @@ -72,6 +75,7 @@ define apache::vhost::static( # run_uid: the uid the vhost should run as with the itk module # run_gid: the gid the vhost should run as with the itk module define apache::vhost::php::standard( + $ensure = present, $domain = 'absent', $domainalias = 'absent', $path = 'absent', @@ -98,33 +102,21 @@ define apache::vhost::php::standard( $htpasswd_file = 'absent', $htpasswd_path = 'absent' ){ - # php upload_tmp_dir - case $upload_tmp_dir { - 'absent': { - include apache::defaultphpdirs - $real_upload_tmp_dir = "/var/www/upload_tmp_dir/$name" - } - default: { $real_upload_tmp_dir = $upload_tmp_dir } - } - # php session_save_path - case $session_save_path { - 'absent': { - include apache::defaultphpdirs - $real_session_save_path = "/var/www/session.save_path/$name" - } - default: { $real_session_save_path = $session_save_path } - } - file{[$real_upload_tmp_dir, $real_session_save_path ]: - ensure => directory, - owner => $run_mode ? { - 'itk' => $run_uid, - default => $documentroot_owner - }, - group => $documentroot_group, - mode => $documentroot_mode; + + apache::vhost::phpdirs{"phpdirs_${name}": + ensure => $ensure, + upload_tmp_dir => $upload_tmp_dir, + session_save_path => $session_save_path, + documentroot_owner => $documentroot_owner, + documentroot_group => $documentroot_group, + documentroot_mode => $documentroot_mode, + run_mode => $run_mode, + run_uid => $run_uid, } + # create webdir apache::vhost::webdir{$name: + ensure => $ensure, path => $path, owner => $owner, group => $group, @@ -135,6 +127,7 @@ define apache::vhost::php::standard( # create vhost configuration file apache::vhost{$name: + ensure => $ensure, path => $path, template_mode => 'php', vhost_mode => $vhost_mode, @@ -166,6 +159,7 @@ define apache::vhost::php::standard( # run_uid: the uid the vhost should run as with the itk module # run_gid: the gid the vhost should run as with the itk module define apache::vhost::php::joomla( + $ensure = present, $domain = 'absent', $domainalias = 'absent', $path = 'absent', @@ -192,30 +186,16 @@ define apache::vhost::php::joomla( $htpasswd_file = 'absent', $htpasswd_path = 'absent' ){ - # php upload_tmp_diR - case $upload_tmp_dir { - 'absent': { - include apache::defaultphpdirs - $real_upload_tmp_dir = "/var/www/upload_tmp_dir/$name" - } - default: { $real_upload_tmp_dir = $upload_tmp_dir } - } - # php session_save_path - case $session_save_path { - 'absent': { - include apache::defaultphpdirs - $real_session_save_path = "/var/www/session.save_path/$name" - } - default: { $real_session_save_path = $session_save_path } - } - file{[$real_upload_tmp_dir, $real_session_save_path ]: - ensure => directory, - owner => $run_mode ? { - 'itk' => $run_uid, - default => $documentroot_owner - }, - group => $documentroot_group, - mode => $documentroot_mode; + + apache::vhost::phpdirs{"phpdirs_${name}": + ensure => $ensure, + upload_tmp_dir => $upload_tmp_dir, + session_save_path => $session_save_path, + documentroot_owner => $documentroot_owner, + documentroot_group => $documentroot_group, + documentroot_mode => $documentroot_mode, + run_mode => $run_mode, + run_uid => $run_uid, } $real_path = $path ? { @@ -230,6 +210,7 @@ define apache::vhost::php::joomla( # create webdir # for the cloning, $documentroot needs to be absent git::clone{"git_clone_$name": + ensure => $ensure, git_repo => "git://git.immerda.ch/ijoomla.git", projectroot => $documentroot, cloneddir_user => $documentroot_owner, @@ -237,39 +218,41 @@ define apache::vhost::php::joomla( } # create and/or put correct permissions apache::vhost::webdir{$name: + ensure => $ensure, path => $real_path, owner => $owner, group => $group, documentroot_owner => $documentroot_owner, documentroot_group => $documentroot_group, documentroot_mode => $documentroot_mode, - documentroot_recurse => false, - require => Git::Clone["git_clone_$name"], + require => Git::Clone["git_clone_$name"], } - $writable_dirs = [ - "$documentroot/administrator/backups", - "$documentroot/administrator/components", - "$documentroot/administrator/language", - "$documentroot/administrator/modules", - "$documentroot/administrator/templates", - "$documentroot/components", - "$documentroot/images", - "$documentroot/language", - "$documentroot/media", - "$documentroot/modules", - "$documentroot/plugins", - "$documentroot/templates", - "$documentroot/cache", - "$documentroot/administrator/cache" - ] - - apache::file::rw{$writable_dirs: - require => Git::Clone["git_clone_$name"] + case $ensure { + absent: { info("don't need to remove additional managed files for ${name} on ${fqdn}")} + default: { + apache::file::rw{ [ "$documentroot/administrator/backups", + "$documentroot/administrator/components", + "$documentroot/administrator/language", + "$documentroot/administrator/modules", + "$documentroot/administrator/templates", + "$documentroot/components", + "$documentroot/images", + "$documentroot/language", + "$documentroot/media", + "$documentroot/modules", + "$documentroot/plugins", + "$documentroot/templates", + "$documentroot/cache", + "$documentroot/administrator/cache" ]: + require => Git::Clone["git_clone_$name"], + } + } } # create vhost configuration file apache::vhost{$name: + ensure => $ensure, path => $path, template_mode => 'php_joomla', vhost_mode => $vhost_mode, @@ -293,7 +276,7 @@ define apache::vhost::php::joomla( mod_security => $mod_security, } - apache::vhost::file::documentrootfile{"joomlaconfigurationfile": + apache::vhost::file::documentrootfile{"joomlaconfigurationfile_${name}": documentroot => $documentroot, filename => 'configuration.php', thedomain => $name, @@ -318,6 +301,7 @@ define apache::vhost::php::joomla( # run_uid: the uid the vhost should run as with the itk module # run_gid: the gid the vhost should run as with the itk module define apache::vhost::modperl( + $ensure = present, $domain = 'absent', $domainalias = 'absent', $path = 'absent', @@ -366,6 +350,7 @@ define apache::vhost::modperl( # create webdir apache::vhost::webdir{$name: + ensure => $ensure, path => $path, owner => $owner, group => $group, @@ -376,6 +361,7 @@ define apache::vhost::modperl( # create vhost configuration file apache::vhost{$name: + ensure => $ensure, path => $path, template_mode => 'perl', vhost_mode => $vhost_mode, -- cgit v1.2.3