From 03fcb575adaee4678490c6ea577fdab94519d54e Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 13 Dec 2012 15:30:14 +0100 Subject: introduce anchor to hook into basic setup --- manifests/base.pp | 98 ++++++++++++---------- manifests/init.pp | 7 +- manifests/vhost/webdir.pp | 205 ++++++++++++++++++++++------------------------ 3 files changed, 152 insertions(+), 158 deletions(-) (limited to 'manifests') diff --git a/manifests/base.pp b/manifests/base.pp index 5f2bac3..1cf2839 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -1,47 +1,57 @@ +# setup base apache class class apache::base { - file{'vhosts_dir': - path => '/etc/apache2/vhosts.d', - ensure => directory, - owner => root, group => 0, mode => 0755; - } - file{'config_dir': - path => '/etc/apache2/conf.d', - ensure => directory, - owner => root, group => 0, mode => 0755; - } - file{'include_dir': - path => '/etc/apache2/include.d', - ensure => directory, - owner => root, group => 0, mode => 0755; - } - file{'modules_dir': - path => '/etc/apache2/modules.d', - ensure => directory, - owner => root, group => 0, mode => 0755; - } - file{'htpasswd_dir': - path => '/var/www/htpasswds', - ensure => directory, - owner => root, group => apache, mode => 0640; - } - file{'web_dir': - path => '/var/www', - ensure => directory, - owner => root, group => 0, mode => 0755; - } - service { apache: - name => 'apache2', - enable => true, - ensure => running, - } - file { 'default_apache_index': - path => '/var/www/localhost/htdocs/index.html', - ensure => file, - content => template('apache/default/default_index.erb'), - owner => root, group => 0, mode => 0644; - } + file{ + 'vhosts_dir': + ensure => directory, + path => '/etc/apache2/vhosts.d', + owner => root, + group => 0, + mode => '0644'; + 'config_dir': + ensure => directory, + path => '/etc/apache2/conf.d', + owner => root, + group => 0, + mode => '0644'; + 'include_dir': + ensure => directory, + path => '/etc/apache2/include.d', + owner => root, + group => 0, + mode => '0644'; + 'modules_dir': + ensure => directory, + path => '/etc/apache2/modules.d', + owner => root, + group => 0, + mode => '0644'; + 'htpasswd_dir': + ensure => directory, + path => '/var/www/htpasswds', + owner => root, + group => 0, + mode => '0640'; + 'web_dir': + ensure => directory, + path => '/var/www', + owner => root, + group => 0, + mode => '0644'; + 'default_apache_index': + path => '/var/www/localhost/htdocs/index.html', + content => template('apache/default/default_index.erb'), + owner => root, + group => 0, + mode => '0644'; + } -> anchor{'apache::basic_dirs::ready': } - apache::config::include{ 'defaults.inc': } - apache::config::global{ 'git.conf': } - apache::vhost::file { '0-default': } + service{'apache': + ensure => running, + name => 'apache2', + enable => true, + } + + apache::config::include{ 'defaults.inc': } + apache::config::global{ 'git.conf': } + apache::vhost::file { '0-default': } } diff --git a/manifests/init.pp b/manifests/init.pp index 572213f..612149d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -12,12 +12,7 @@ # the Free Software Foundation. # -# Global variables: -# -# $apache_default_user: Set this to the user with which the -# apache is running. -# $apache_default_group: Set this to the group with which the -# apache is running. +# manage a simple apache class apache( $cluster_node = '', $manage_shorewall = false, diff --git a/manifests/vhost/webdir.pp b/manifests/vhost/webdir.pp index e9eda1b..a6ec229 100644 --- a/manifests/vhost/webdir.pp +++ b/manifests/vhost/webdir.pp @@ -1,125 +1,114 @@ # create webdir define apache::vhost::webdir( - $ensure = present, - $path = 'absent', - $owner = root, - $group = apache, - $mode = 0640, - $run_mode = 'normal', - $manage_docroot = true, - $documentroot_owner = root, - $documentroot_group = apache, - $documentroot_mode = 0640, - $documentroot_recurse = false + $ensure = present, + $path = 'absent', + $owner = root, + $group = apache, + $mode = 0640, + $run_mode = 'normal', + $manage_docroot = true, + $documentroot_owner = root, + $documentroot_group = apache, + $documentroot_mode = 0640, + $documentroot_recurse = false ){ - $real_path = $path ? { - 'absent' => $::operatingsystem ? { - openbsd => "/var/www/htdocs/${name}", - default => "/var/www/vhosts/${name}" - }, - default => "${path}" - } + $real_path = $path ? { + 'absent' => $::operatingsystem ? { + openbsd => "/var/www/htdocs/${name}", + default => "/var/www/vhosts/${name}" + }, + default => $path + } - if (($run_mode =~ /^(static\-|proxy\-)?itk$/) or $run_mode == 'fcgid') and ($mode == '0640'){ - $real_mode = 0644 - } else { - $real_mode = $mode - } + if (($run_mode =~ /^(static\-|proxy\-)?itk$/) or $run_mode == 'fcgid') and ($mode == '0640'){ + $real_mode = 0644 + } else { + $real_mode = $mode + } - $documentroot = "${real_path}/www" - $logdir = "${real_path}/logs" + $documentroot = "${real_path}/www" + $logdir = "${real_path}/logs" - if $owner == 'apache' { - if $apache_default_user == '' { - $real_owner = $::operatingsystem ? { - openbsd => 'www', - debian => 'www-data', - default => $owner - } - } else { - $real_owner = $apache_default_user - } - } else { - $real_owner = $owner + if $owner == 'apache' { + $real_owner = $::operatingsystem ? { + openbsd => 'www', + debian => 'www-data', + default => $owner } - if $group == 'apache' { - if $apache_default_group == '' { - $real_group = $::operatingsystem ? { - openbsd => 'www', - debian => 'www-data', - default => $group - } - } else { - $real_group = $apache_default_group - } - } else { - $real_group = $group + } else { + $real_owner = $owner + } + if $group == 'apache' { + $real_group = $::operatingsystem ? { + openbsd => 'www', + debian => 'www-data', + default => $group } + } else { + $real_group = $group + } - if $documentroot_owner == 'apache' { - if $apache_default_user == '' { - $real_documentroot_owner = $::operatingsystem ? { - openbsd => 'www', - debian => 'www-data', - default => $documentroot_owner - } - } else { - $real_documentroot_owner = $apache_default_user - } - } else { - $real_documentroot_owner = $documentroot_owner + if $documentroot_owner == 'apache' { + $real_documentroot_owner = $::operatingsystem ? { + openbsd => 'www', + debian => 'www-data', + default => $documentroot_owner } - if $documentroot_group == 'apache' { - if $apache_default_group == '' { - $real_documentroot_group = $::operatingsystem ? { - openbsd => 'www', - debian => 'www-data', - default => $documentroot_group - } - } else { - $real_documentroot_group = $apache_default_group + } else { + $real_documentroot_owner = $documentroot_owner + } + if $documentroot_group == 'apache' { + $real_documentroot_group = $::operatingsystem ? { + openbsd => 'www', + debian => 'www-data', + default => $documentroot_group + } + } else { + $real_documentroot_group = $documentroot_group + } + case $ensure { + absent: { + file{$real_path: + ensure => absent, + purge => true, + recurse => true, + force => true; } - } else { - $real_documentroot_group = $documentroot_group } - case $ensure { - absent: { - if $manage_docroot { - $managed_directories = [ $real_path, "${real_path}/private", $logdir, $documentroot ] - } else { - $managed_directories = [ $real_path, "${real_path}/private", $logdir ] - } - file{$managed_directories: - ensure => absent, - purge => true, - recurse => true, - force => true, - } + default: { + file{ + $real_path: + ensure => directory, + require => Anchor['apache::basic_dirs::ready'], + owner => $real_owner, + group => $real_group, + mode => $real_mode; + $logdir: + ensure => directory, + owner => $real_documentroot_owner, + group => $real_documentroot_group, + mode => '0660'; + "${real_path}/private": + ensure => directory, + owner => $real_documentroot_owner, + group => $real_documentroot_group, + mode => '0600'; + } + if $manage_docroot { + file{$documentroot: + ensure => directory, + recurse => $documentroot_recurse, + owner => $real_documentroot_owner, + group => $real_documentroot_group, + mode => $documentroot_mode; } - default: { - file{$real_path: - ensure => directory, - owner => $real_owner, group => $real_group, mode => $real_mode; - } - if $manage_docroot { - 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 => $real_documentroot_group, mode => 0660; - } - case $::operatingsystem { - centos: { include apache::logrotate::centos::vhosts } - } - file{"${real_path}/private": - ensure => directory, - owner => $real_documentroot_owner, group => $real_documentroot_group, mode => 0600; - } + } + case $::operatingsystem { + centos: { include apache::logrotate::centos::vhosts } + default: { #nothing } + } } + } } -- cgit v1.2.3