puppet apache vhost 模板引用一例

/etc/puppet/modules/apache/manifests/init.pp

define site ( $sitedomain = "", $documentroot = "" ) {
      include apache
if $sitedomain == ""
{
    $vhost_domain = $name
}
else
{
    $vhost_domain = $sitedomain
}
if $documentroot == ""
{
   $vhost_root = "/var/www/${name}"
}
else
{
   $vhost_root = $documentroot
}
file { "/etc/apache2/sites-available/${vhost_domain}. conf":
      content => template("apache/vhost.erb"),
      require => File["/etc/apache2/conf.d/name-based- vhosts.conf"],
      notify => Exec["enable-${vhost_domain}-vhost"],
      }
exec { "enable-${vhost_domain}-vhost":
       command => "/usr/sbin/a2ensite ${vhost_domain}. conf",
       require => [ File["/etc/apache2/sites- available/${vhost_domain}.conf"],
       Package["apache2-mpm-prefork"] ,
       refreshonly => true,
       notify => Service["apache2"],
}
}

/etc/puppet/modules/apache/templates/vhost.erb

<VirtualHost *:80>
ServerName <%= vhost_domain %>
ServerAdmin admin@<%= vhost_domain %>
DocumentRoot <%= vhost_root %>
ErrorLog logs/<%= vhost_domain %>-error_log
CustomLog logs/<%= vhost_domain %>-access_log common
<Directory /var/www/<%= vhost_domain %>>
Allow from all
Options +Includes +Indexes +FollowSymLinks
AllowOverride all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.<%= vhost_domain %>
Redirect 301 / http://<%= vhost_domain %>/

</VirtualHost> apache

轉發地址:http://my.safaribooksonline.com/book/-/9781849515382/applications/ch07lvl1sec02 app

相關文章
相關標籤/搜索