I'm using cfengine to start the foobar process. Apparently the LHS is discarded when I use process_select? Can I simply pass the LHS to a function, rather than having to put the command match pattern in a body argument?
I wanted to only match foobar
processes belonging to a particular user, since another user could easily be running foobar
for testing.
bundle agent foobar {
processes:
"foobar" # documented way would be to use .* here
process_select => command("foobar"),
restart_class => start_foobar;
commands:
start_foobar::
"/usr/bin/foobar";
}
body process_select command(c) {
command => "$(c)";
process_result => "command";
}
As far as I know, if you just want to look for the "foobar" process, you don't need to use the
process_select
feature at all.Can't you just do this?
If you also need to match other criteria at the same time, like the user running it as you suggest, I would recommend either using a variable like:
Or, better still, writing a bundle that takes some parameters, something like this:
And then just call this bundle as restart("foobar", "/usr/bin").
I haven't tested the code above, you might have to tweak it!