-
Notifications
You must be signed in to change notification settings - Fork 214
Currently it is not possible to indicate hosts or groups for batches to run on within the batch definition.
batch 'run_pre_upgrade_tasks', group => 'testing_servers', qw( task1 task2 task3 );
This syntax could be useful to have.
All reactions
Replies: 1 comment
Currently it is not possible to indicate hosts or groups for batches to run on within the
batchdefinition.
That's because a batch is not intended to be more than an ordered list of tasks to execute one by one sequentially. A task is a combination of code ("what to execute") and target ("where to execute").
The target needs to be specified either as part of the task definition ("default target" for the task), or given on the CLI as with -H (for hosts) and -G (for host groups) to force it.
If a sequence of tasks need to be codified with anything more than their ordering, I recommend creating another task which calls all the others as needed. For example:
task 'run_pre_upgrade_tasks', group => 'testing_servers', sub { # different styles are available to call other tasks, choose one or more according to the requirements do_task 'task1'; # run `task1` exactly as that is defined run_task 'task2'; # run `task2` as defined, optionally overriding its target and/or pass parameters task3(); # run `task3`, calling it as a function (and for example pass parameters to it) needs 'task4'; # depend on `task4` (more or less "run it with already established parameters and connection") };
That's a very similar syntax as suggested initially, more flexible than a batch, and already works without developing/maintaining/supporting a new feature :)