When using a custom connect_kwargs with a key_filename option, like so:
config = fabric.config.Config()
print("Connecting with ssh/config")
with fabric.Connection(
host=instancePrivateIp,
user='ec2-user',
config=config,
connect_kwargs={
"key_filename": keyFileName,
}) as c_instance:
I get an AttributeError:
File "/home/dumontj/Projects/ami-builder/ami_builder/customization.py", line 26, in do_bash_customization
"key_filename": keyFileName,
File "/home/dumontj/.local/share/virtualenvs/ami-builder-jbdgQc96/lib/python3.7/site-packages/fabric/connection.py", line 450, in __init__
self.connect_kwargs = self.resolve_connect_kwargs(connect_kwargs)
File "/home/dumontj/.local/share/virtualenvs/ami-builder-jbdgQc96/lib/python3.7/site-packages/fabric/connection.py", line 490, in resolve_connect_kwargs
connect_kwargs["key_filename"].extend(
AttributeError: 'str' object has no attribute 'extend'
The documentation specifies that key_filename should be given as a string, but I found that it works if you actually give it a list:
with fabric.Connection(
host=instancePrivateIp,
user='ec2-user',
config=config,
connect_kwargs={
"key_filename": [keyFileName,],
}) as c_instance:
If this is the wanted syntax, I can update the documentation through a PR (see https://github.com/fabric/fabric/blob/2.0/fabric/connection.py#L234). Otherwise I could change fabric/connection.py to check whether there is already an entry, then transform it into a list if necessary.
When using a custom
connect_kwargswith akey_filenameoption, like so:I get an
AttributeError:The documentation specifies that
key_filenameshould be given as a string, but I found that it works if you actually give it a list:If this is the wanted syntax, I can update the documentation through a PR (see https://github.com/fabric/fabric/blob/2.0/fabric/connection.py#L234). Otherwise I could change
fabric/connection.pyto check whether there is already an entry, then transform it into a list if necessary.