Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 35 additions & 9 deletions molecule_ec2/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,41 @@ def name(self, value):

@property
def login_cmd_template(self):
connection_options = " ".join(self.ssh_connection_options)

return (
"ssh {{address}} "
"-l {{user}} "
"-p {{port}} "
"-i {{identity_file}} "
"{}"
).format(connection_options)
if self._config.command_args.get("host"):
hostname = self._config.command_args["host"]
elif len(self._config.platforms.instances) == 1:
hostname = self._config.platforms.instances[0]["name"]
else:
LOG.error("Please specify instance via '--host'")
sys.exit(1)

ansible_connection_options = self.ansible_connection_options(hostname)
if ansible_connection_options.get("ansible_connection") == "winrm":
return (
"xfreerdp "
'"/u:%s" '
'"/p:%s" '
"/v:%s "
"/cert-tofu "
"+clipboard "
"/grab-keyboard"
% (
ansible_connection_options["ansible_user"],
ansible_connection_options["ansible_password"],
ansible_connection_options["ansible_host"],
)
)

else: # normal ssh connection
connection_options = " ".join(self.ssh_connection_options)

return (
"ssh {{address}} "
"-l {{user}} "
"-p {{port}} "
"-i {{identity_file}} "
"{}"
).format(connection_options)

@property
def default_safe_files(self):
Expand Down