You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to provide some parameter for your task, you can easily do it this way.
desc "Add a new user";
task "useradd", "server1", "server2", sub {
my ($params) = @_;
run "useradd -m " . $params->{'username'};
run "echo " . $params->{'username'} . ":" . $params->{'password'} ." |chpasswd";
};
And call it:
rex useradd --username=user1 --password=securepw
Note: Passing parameters cannot be done to a batch command. If you wish to do this bundle tasks in the following fashion and then call that task as above.
use Data::Dumper;
task "task1", sub {
print Dumper(\@_);
};
task "task2", sub {
print Dumper(\@_);
};
task "task1and2", sub {
#List of tasks start and end /task1...n/
do_task [qw/task1 task2/];
};