Custom apache module advice needed

34 views
Skip to first unread message

Ugo Bellavance

unread,
Nov 24, 2014, 12:38:33 PM11/24/14
to puppet...@googlegroups.com
Hi,

I've written my own puppet module for apache because I found that the publicly-available ones had many dependencies or were too complex for me.  I'm not a puppet expert and I'm using EPEL's puppet which is 2.7.25.

Here is the relevant part of my code that is used to create the apache .conf file for our environments.  Our environments follow this standard:

for dev:  /var/www/dev/$user/$application/

for other environments stages: /var/www/$envstage/$application/

The logs are located in a directory called "logs" in the $application folder.

My current puppet codes does everything that is needed to create an environment, but it doesn't manage the order, so it may happen that the logs folder is created after the apache refresh and cause a problem.

I have a few (less-related) questions regarding this:
  • Does puppet manage the creation of the parent directories as of now?
  • I've had unplanned outages (nothing critical, clients/users were warned on dev and staging environments) because the refresh was done before the logs directory was created
    • Should I implement file syntax checking for httpd .conf files?  Should it be on file-level or should it be in the refresh parameter of the service? (Something similar to restart => '/usr/sbin/apachectl -t && /etc/init.d/httpd graceful',

When I add a require => File directives, it fails with an error that looks like that:

Duplicate parameter 'require' for on File[/etc/httpd/conf.d/blabla-integration1.conf] at /etc/puppet/modules/apache/manifests/vhost.pp

Here is the relevant part of my code:


    $logdir = "$vhost_base/logs"

  if $envstage  != 'dev' {
    file { [ "$logdir", "/var/www/$envstage", "$vhost_base", ]:
      ensure => 'directory',
      owner  => 'deploy',
      group  => 'deploy',
      mode   => 0744,
  }
}
# Generate the .conf file for the vhost
    file {
        "${vdir}/${name}.conf":
        content => template($template),
        owner   => 'root',
        group   => 'root',
        mode    => '0644',
        require => "$logdir",
        require => Package['httpd'],
        notify  => Service['httpd'],
    }

What would be the best way to manage that?  Separate my file resources in 3 separate directives?

Thanks

Ugo

Ugo Bellavance

unread,
Nov 24, 2014, 8:37:24 PM11/24/14
to puppet...@googlegroups.com
Sorry for top-posting, but I found my mistake.  I didn't know we could not set 'require' more than once.  It now looks obvious but it wasn't when I was working on it.

Ugo

Pete Brown

unread,
Nov 25, 2014, 12:47:38 AM11/25/14
to puppet...@googlegroups.com


On 25 Nov 2014 11:37, "Ugo Bellavance" <ug...@lubik.ca> wrote:
>
> Sorry for top-posting, but I found my mistake.  I didn't know we could not set 'require' more than once.  It now looks obvious but it wasn't when I was working on it.

You can require multiple resources but they need to be in an array.

> --
> 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/be4870e2-f4d5-4f7e-a64b-1c9242800096%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Ashish Jaiswal

unread,
Nov 25, 2014, 2:10:24 AM11/25/14
to puppet...@googlegroups.com, Pete Brown
Hi,

Something like this .
$baseos_dir = [
"/opt/",
"/opt/bin/",
"/opt/other",
"/opt/other/src",
"/opt/other/nosrc",
"/opt/other/downloads",
"/opt/other/javalib",
"/opt/man",
"/opt/man/man1"
]

file { $baseos_dir : ensure => directory }

On Tuesday 25 November 2014 11:17 AM, Pete Brown wrote:
>
>
> On 25 Nov 2014 11:37, "Ugo Bellavance" <ug...@lubik.ca
> <mailto:puppet-users%2Bunsu...@googlegroups.com>.
> --
> 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
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/CAM8R_x_k9Sz4fSz0%3DLXbimK0kb3DwS7iejP2Cf5Q5kaMqre_0A%40mail.gmail.com
> <https://groups.google.com/d/msgid/puppet-users/CAM8R_x_k9Sz4fSz0%3DLXbimK0kb3DwS7iejP2Cf5Q5kaMqre_0A%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Ugo Bellavance

unread,
Nov 25, 2014, 3:32:37 PM11/25/14
to puppet...@googlegroups.com


On Tuesday, November 25, 2014 12:47:38 AM UTC-5, Pete Brown wrote:


On 25 Nov 2014 11:37, "Ugo Bellavance" <ug...@lubik.ca> wrote:
>
> Sorry for top-posting, but I found my mistake.  I didn't know we could not set 'require' more than once.  It now looks obvious but it wasn't when I was working on it.

You can require multiple resources but they need to be in an array.


Exactly, it's now fixed and working, thanks! 

Ugo Bellavance

unread,
Nov 25, 2014, 3:36:13 PM11/25/14
to puppet...@googlegroups.com

  • I've had unplanned outages (nothing critical, clients/users were warned on dev and staging environments) because the refresh was done before the logs directory was created
    • Should I implement file syntax checking for httpd .conf files?  Should it be on file-level or should it be in the refresh parameter of the service? (Something similar to restart => '/usr/sbin/apachectl -t && /etc/init.d/httpd graceful',
The answer is to use the restart => definition. Graceful causes no interruption.
 
Reply all
Reply to author
Forward
0 new messages