Yes Nick, that's a good example implementation. You could also pull from a database or load a config file with the info.
On Fri, Dec 9, 2016 at 4:33 PM Nick Timkovich <[email protected]> wrote: > I like Brandon's first notion: "have your task query for what param it > should use based on the value of env.host_string", which seems like a much > better idea than the second that he gave an example for. I might be barking > up the wrong tree, but would something like the following work? > > @parallel > def task(param_table): > param = param_table[env.host_string] > run("command with {}".format(param)) > > def launcher(): > param_table = { > '192.168.1.100': 'param1', > '192.168.1.200': 'param2', > } > execute(task, param_table, hosts=list(param_table)) > > > On Fri, Dec 9, 2016 at 1:05 PM, Brandon Whaley <[email protected]> wrote: > > Glad to help! > > On Fri, Dec 9, 2016, 14:04 Erikton Konomi <[email protected]> wrote: > > Thanks Brandon! This is very helpful. > > On Thu, Dec 8, 2016 at 3:46 PM, Brandon Whaley <[email protected]> wrote: > > That functionality is not built in to fabric. Either have your task query > for what param it should use based on the value of env.host_string or abuse > host strings to pass the arguments like so: > > @parallel > def task(): > #naturally requires that param not contain '_', use another non-valid > host character if it needs to > host_string, param = env.host_string.split('_') > with settings(host_string=host_string): > run("command with {}".format(param)) > > def launcher(): > execute(task, hosts=['192.168.1.100_param1', '192.168.1.200_param2']) > > On Thu, Dec 8, 2016 at 6:05 PM Erikton Konomi <[email protected]> wrote: > > Hello, > > How would you go about running multiple tasks on multiple hosts but with > different parameter for each host? For example a fabfile with: > > @parallel > def task(param): > run("some command that takes <param> as argument") > > def launcher(): > execute(task, param_1, hosts=['192.168.1.100', '192.168.1.200']) > # The above will run the task on 2 hosts but with the same value for > <param> > # I would like to run both hosts but specifying different value for > <param> for each host, like: > # execute(task, args=[param_1, param_2], hosts=['192.168.1.100', > '192.168.1.200']) > > Is this functionality there? I couldn't find something on the documents. > > Thanks, > Erik > > _______________________________________________ > Fab-user mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/fab-user > > > > _______________________________________________ > Fab-user mailing list > [email protected] > https://lists.nongnu.org/mailman/listinfo/fab-user > > >
_______________________________________________ Fab-user mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/fab-user
