We have a base 'nginx' class, and nodes' classes include this base class and add their configuration files under /etc/nginx/conf.d
I'd like to have the nginx service subscribe to /etc/nginx/conf.d in a single location, so that people writing the nodes' classes don't have to remember to add notify => Service['nginx']
. I've tried using this Puppet code below, but it didn't work (ie, after I modified application.conf, the nginx service wasn't reloaded).
Is this possible?
modules/nginx/init.pp
class nginx {
package { 'nginx':
ensure => installed,
}
service { 'nginx':
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
require => Package['nginx'],
subscribe => File['/etc/nginx', '/etc/nginx/conf.d'],
}
file { ['/etc/nginx', '/etc/nginx/conf.d']:
ensure => directory,
owner => application,
group => application,
recurse => true,
}
}
modules/application/init.pp
class application {
file {'/etc/nginx/conf.d/application.conf':
ensure => present,
owner => application,
group => application,
source => 'puppet:///modules/application/application.conf',
require => Package['nginx'],
}
}