Jesse,
you can have no less than two promises (since your process_count
condition cannot be combined with process_select condition):
bundle agent httpd
{
vars:
"apache_users" slist => { "root", "www", "apache" };
processes:
Webservers::
"/usr/sbin/httpd"
process_count => outrange("httpd", "1", "2"),
comment => "Ensure process count";
"/usr/sbin/httpd"
process_select => not_owned_by("@(apache_users)"),
signals => { 'term', 'quit', 'kill' },
restart_class => "StartHTTPD"
comment => "Ensure Apache is up and running
with proper ownership";
commands:
StartHTTPD|httpd_stragglers::
"/etc/init.d/httpd restart" comment => "Apache needs to be
(re)started";
}
body process_count outrange(name, min, max)
{
match_range => "1,2";
in_range_define => { '$(name)_stragglers' };
}
body process_select not_owned_by(x)
{
process_owner => { @(x) };
process_result => "!process_owner";
}
If you specifically want to perform an arbitrary kill when process
count mismatches, you'll need three process promises.
2011/3/12 Jesse Becker <[email protected]>:
> I'm working an a bundle for Apache, and specifically the processes:
> section. I have several conditions:
>
> * If httpd not running, start it.
>
> * If httpd not running as root/apache, kill current processes, and start
> the daemon properly.
>
> * If there are "too few" httpd processes (i.e. 1-2), kill them, and
> restart.
>
>
> As best I can figure, this requires three separate promises, and at
> least two more bodies in support. Am I completely missing a simpler
> solution here?
>
> <----snip---->
>
> bundle httpd {
>
> processes:
> Webservers::
> "/usr/sbin/httpd"
> process_count => httpd_stragglers,
> signals => { 'term', 'quit', 'kill' },
> comment => "Kill off stragglers: if only 1 or 3 procs
> present, it's probably broken.";
>
> "/usr/sbin/httpd"
> process_select => not_apache_user,
> signals => { 'term', 'quit', 'kill' },
> comment => "Kill off httpd processes not owned by either
> 'root' or 'apache'";
>
> "/usr/sbin/httpd"
> restart_class => "StartHTTPD",
> comment => "Start apache if it isn't running";
>
> }
>
>
> body process_count httpd_stragglers {
> match_range => "1,2";
> in_range_define => { 'httpd_stragglers' };
> }
>
> body process_select apache_user {
> process_owner => { 'root', 'www', 'apache' };
> process_result => "process_owner";
> }
>
>
> <----snip---->
>
> --
> Jesse Becker
> NHGRI Linux support (Digicon Contractor)
> _______________________________________________
> Help-cfengine mailing list
> [email protected]
> https://cfengine.org/mailman/listinfo/help-cfengine
>
--
SY, Seva Gluschenko.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine