I think you're overcomplicating.
I suppose you have something like
class mywebapp {
tomcat7::war { "mywebapp": ... }
}
You can wrench your code inbetween if you slightly modify your defined
type like so:
define tomcat7::war(...) {
file { "tomcat7-war-file-$name":
path => "${tomcat7::sites_dir}/${destFile}",
notify => Exec["clean-tomcat7-war-$name"],
}
exec { "clean-tomcat7-war-$name":
...
}
}
to make the interface more transparent. Then add to class mywebapp:
exec { "notify-loadbalancer":
command => ...
suscribe => File["tomcat7-war-file-mywebapp"],
before => Exec["clean-tomcat7-war-mywebapp"],
}
This is not exactly clean design, of course (use this pattern in enough
places and you've got a maintenance nightmare right on hand).
If you *want* to make it clean, you will have little choice but to
include the code in tomcat7::war after all, along with a new parameter
to explicitly enable it (e.g. $do_notify_loadbalancer = false).
If a compromise is acceptable, you may get away with making it somewhat
generic like
define tomcat7::war(
...
$pre_cleanup_hook = "") {
...
if $pre_cleanup_hook {
exec { "tomcat7-war-pch-$name":
command => "$pre_cleanup_hook",
subscribe => File[...],
before => Exec[...],
}
}
...
}
HTH,
Felix
On 11/26/2013 07:31 AM, Joshua Chaitin-Pollak wrote:
what I would like to do is pass a parameter into tomcat::war so that if
that the parameter is set, the class (or type) referenced in the
parameter is Notified instead
of Exec["clean_${tomcat7::sites_dir}/${contextPath}"], and
then Exec["clean_${tomcat7::sites_dir}/${contextPath}"] would be
notified AFTER my code.
This would allow my code a chance to notify the load balancer and pause
before cleaning and restarting tomcat. I don't want the special
load-balancer code in tomcat::war, because it is unique to 'mywebapp'.
Is there a way to do this at all?
--what I would like to do is pass a parameter into tomcat::war so that if
that the parameter is set, the class (or type) referenced in the
parameter is Notified instead
of Exec["clean_${tomcat7::sites_dir}/${contextPath}"], and
then Exec["clean_${tomcat7::sites_dir}/${contextPath}"] would be
notified AFTER my code.
This would allow my code a chance to notify the load balancer and pause
before cleaning and restarting tomcat. I don't want the special
load-balancer code in tomcat::war, because it is unique to 'mywebapp'.
Is there a way to do this at all?
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 [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/5295C8B3.8000705%40alumni.tu-berlin.de.
For more options, visit https://groups.google.com/groups/opt_out.