I've the following Puppet manifest:
# PHP Configuration
class php {
exec { "php5enmod $module":
path => "/usr/sbin",
command => "php5enmod $module",
}
file {'/etc/php5/conf.d/upload_limits.ini':
ensure => present,
owner => root, group => root, mode => 444,
notify => [ Exec["php5enmod upload_limits"], Service["apache2"] ],
content => "post_max_size = 16M \nupload_max_filesize = 16M \n",
}
file {'/etc/php5/conf.d/memory_limits.ini':
ensure => present,
owner => root, group => root, mode => 444,
notify => [ Exec["php5enmod memory_limits"], Service["apache2"] ],
content => "memory_limit = 256M \n",
}
}
include php
How I can create exec
to use in notify
by passing the parameter dynamically? It's something that's possible, or there is another better way of doing it?
The current code gives me errors like:
Error: Could not find dependent Exec[php5enmod upload_limits] for File[/etc/php5/conf.d/upload_limits.ini]
When this is running the
exec
first gets declared.At that point $module is not set, so the exec title is
php5enmod
.You are not passing a variable here, this is just a name.
In such a case a defined type makes more sense.
Like this:
Normally the
define
shouldn't be there.It should probably be
php::php5enmod()
and have it's own file.This is just to show the general concept.
Reverse your thinking! Use
Subscribe
to link your variably-namedExec
(bad form, IMHO) to theFile
.Subscribe and Notify
are complimentary; they do the same thing, but in differing directions.Try something like this?
Completely untested, but I think that'll get you started at least...