user1513388
user1513388

Reputation: 7441

Fabric - Passing arguments to tasks via execute

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?

Upvotes: 13

Views: 7348

Answers (1)

jfs
jfs

Reputation: 414129

execute(ssh_keygen, 'jbloggs', '/home/jbloggs', host="server1")

Upvotes: 16

Related Questions