Skip to content

Commit

Permalink
Always apply ssh_connection_options (#4174)
Browse files Browse the repository at this point in the history
Always apply `ssh_connection_options` whether we use `identity_file` or
password.

Default `ssh_connection_options` include `UserKnownHostsFile=/dev/null`
and ` StrictHostKeyChecking=no` but those options are never applied if
no `identity_file` parameter is supplied along with the instance config.

This pull request changes the default driver to always use
`ssh_connection_options` whether `identity_file` or `password` is used.
  • Loading branch information
wokis authored Apr 30, 2024
1 parent 1fd6da5 commit cb74c54
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/molecule/driver/delegated.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,16 @@ def ansible_connection_options(self, instance_name):

if d.get("identity_file", None):
conn_dict["ansible_private_key_file"] = d.get("identity_file")
conn_dict["ansible_ssh_common_args"] = " ".join(
self.ssh_connection_options,
)
if d.get("password", None):
conn_dict["ansible_password"] = d.get("password")
# Based on testinfra documentation, ansible password must be passed via ansible_ssh_pass
# issue to fix this can be found https://github.com/pytest-dev/pytest-testinfra/issues/580
conn_dict["ansible_ssh_pass"] = d.get("password")

conn_dict["ansible_ssh_common_args"] = " ".join(
self.ssh_connection_options,
)

return conn_dict

except StopIteration:
Expand Down

0 comments on commit cb74c54

Please sign in to comment.