Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fabric - Passing arguments to tasks via execute

Tags:

python

fabric

I have the following Fabric task:

def ssh_keygen(user, dir):
   env.user = user
   run("ssh-keygen  %s" % dir)

I want to call it using "execute" but need to pass the task an argument. i.e. user and dir

execute(ssh_keygen('jbloggs', '/home/jbloggs'), hosts=["server1"])

However this does not work:

No hosts found. Please specify (single) host string for connection: Traceback (most recent 

Is there anyway to achieve this?

like image 740
user1513388 Avatar asked Mar 28 '14 10:03

user1513388


1 Answers

execute(ssh_keygen, 'jbloggs', '/home/jbloggs', host="server1")
like image 98
jfs Avatar answered Oct 17 '22 08:10

jfs