Hello everyone,
I’m using the Ansible 2 module in Python to connect to a host with different port (not 22)
The script I’m using is:
https://github.com/ansible/ansible/blob/devel/examples/scripts/uptime.py
But my ssh port in the host i’m trying to connect to is 2222,
so I changed it to this:
def main():
host_list = [‘10.0.0.10’]
Options = namedtuple(‘Options’, [‘connection’,‘module_path’, ‘forks’, ‘remote_user’,
‘private_key_file’, ‘ssh_common_args’, ‘ssh_extra_args’, ‘sftp_extra_args’,
‘scp_extra_args’, ‘become’, ‘become_method’, ‘become_user’, ‘verbosity’, ‘check’])
initialize needed objects
variable_manager = VariableManager()
loader = DataLoader()
options = Options(connection=‘smart’, module_path=‘/usr/share/ansible’, forks=100,
remote_user=‘user’, private_key_file=None, ssh_common_args=None, ssh_extra_args=None,
sftp_extra_args='-P 2222 ', scp_extra_args=None, become=None, become_method=None,
become_user=None, verbosity=None, check=False)
But i’m getting a error:
DOWN *********
10.0.0.10 >>> Failed to connect to the host via ssh.
Any ideas?
Thank you