|
From: | Christian MacNevin |
Subject: | [Fab-user] New to fabric 2. Using groups with Connection? |
Date: | Mon, 23 Jul 2018 22:45:16 +0000 |
Hi all, I’m new to Fabric 2, though in the past I’d used 1 a lot. I can find docs on using SerialGroup, but only with run directly. I’m using interactive mode authentication, so it seems like I need to gather a password (that’s fine, I’m doing
it via getpass) and also pass kwargs into Connection. I have a large list of hosts, and also was planning to use @task decorators. What I have right now is a muddle between the two which obviously won’t work, but I can’t figure out how to glue the three import getpass from fabric import Connection, group from invoke import task switch_group = group.SerialGroup(switch1', 'switch2', 'switch3') pw = getpass.getpass("Password for netuser?") @task def inventory(c): ß This is purely here because tasks will error out if a kwarg ‘Context(..?)’ isn’t specified with Connection(user = 'user', connect_kwargs = {'password' : pw }) as c: switch_group.run('show chassis hardware') It’s failing out with ’TypeError: __init__() takes at least 2 arguments (3 given)’ |
[Prev in Thread] | Current Thread | [Next in Thread] |