apache::vhost add prefix to logfiles

65 views
Skip to first unread message

Denny

unread,
Oct 24, 2014, 3:32:28 AM10/24/14
to puppet...@googlegroups.com
Hi there,

this is - for sure - pretty easy to solve but I'm a bit stuck right now...

I want to add a prefix to my apache-vhost access and error logs depending on what kind of application is installed on this vhost

Right now my config looks something like this:

apache::vhost { 'vhost.example.com':
  port            => '80',
  docroot         => '/var/www/html/someprettywebsite',
  serveradmin     => 'dontc...@example.com',
}

which produces two log files: 
/var/log/http/vhost.example.com_error.log 
/var/log/http/vhost.example.com_access.log


but what I want is something like:

/var/log/http/wordpress_vhost.example.com_error.log 
/var/log/http/wordpress_vhost.example.com_access.log

I've tried things like the example below, but didn't work :(

apache::vhost { 'vhost.example.com':
  port            => '80',
  docroot         => '/var/www/html/someprettywebsite',
  serveradmin     => 'dontc...@example.com',
  access_log_file => "wordpress_${access_log_file}",
}


Any suggestions are welcome,

Denny

Christopher Webber

unread,
Oct 24, 2014, 7:35:23 AM10/24/14
to puppet...@googlegroups.com
Denny,

Which apache module are you using?

— cwebber

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/aaaa0931-1ab3-462a-9441-2ded4a79a879%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Denny

unread,
Oct 24, 2014, 8:17:56 AM10/24/14
to puppet...@googlegroups.com
puppetlabs-apache (v1.1.1)

Christopher Webber

unread,
Oct 24, 2014, 8:27:47 AM10/24/14
to puppet...@googlegroups.com
Ok,

So when you call `access_log_file => “wordpress_${access_log_file}”` puppet is pulling $access_log_file from the scope in which you called apache::vhost what you probably want to do is something like:

$vhost_name = ‘vhost.example.com'
$vhost_type = ‘wordpress’

apache::vhost {$vhost_name:
  port            => 80,
  docroot         => "/var/www/html/${vhost_name}”,
  serveradmin     => ‘ihaz...@mail.com’,
  access_log_file => “${vhost_type}_${vhost_name}_access.log”,
  error_log_file  => “${vhost_type}_${vhost_name}_error.log”
}

Denny

unread,
Oct 24, 2014, 8:41:21 AM10/24/14
to puppet...@googlegroups.com
thanks, but this would be far to much work for like 100 vhosts, which I want to sort into 2-3 groups of vhosts

in fact, it's probably easier to put them into different directories

Christopher Webber

unread,
Oct 24, 2014, 8:51:03 AM10/24/14
to puppet...@googlegroups.com
Maybe do something with create_resources and hiera? It has been a while since I have done it so I don’t have code handy but it is worth looking at.

— cwebber

L Wilson

unread,
Oct 26, 2014, 8:47:37 PM10/26/14
to puppet...@googlegroups.com
try adding a servername param to your vhost config. 

ie from docs: 
apache::vhost { 'first.example.com non-ssl':
  servername => 'first.example.com',
  port       => '80',
  docroot    => '/var/www/first',
}
Reply all
Reply to author
Forward
0 new messages