From 9be8ecda0668631a69883ec69ae6eeab1abef848 Mon Sep 17 00:00:00 2001 From: Alexey Shabalin Date: Thu, 14 Jan 2016 13:01:49 +0300 Subject: [PATCH] Add support ssh configs from /etc/openssh. In Altlinux system config dir for openssh is /etc/openssh. --- lib/ansible/module_utils/facts.py | 2 ++ lib/ansible/module_utils/known_hosts.py | 1 + lib/ansible/plugins/connection/paramiko_ssh.py | 12 +++++++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index a8c53eda3d..3ce5b14820 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -536,6 +536,8 @@ class Facts(object): keydir = '/etc/ssh' else: keydir = '/etc' + if self.facts['distribution'] == 'Altlinux': + keydir = '/etc/openssh' else: keydir = '/etc/ssh' diff --git a/lib/ansible/module_utils/known_hosts.py b/lib/ansible/module_utils/known_hosts.py index 52b0bb74b0..09d08b20ef 100644 --- a/lib/ansible/module_utils/known_hosts.py +++ b/lib/ansible/module_utils/known_hosts.py @@ -119,6 +119,7 @@ def not_in_host_file(self, host): host_file_list.append(user_host_file) host_file_list.append("/etc/ssh/ssh_known_hosts") host_file_list.append("/etc/ssh/ssh_known_hosts2") + host_file_list.append("/etc/openssh/ssh_known_hosts") hfiles_not_found = 0 for hf in host_file_list: diff --git a/lib/ansible/plugins/connection/paramiko_ssh.py b/lib/ansible/plugins/connection/paramiko_ssh.py index ab9ce90db9..52bbdf05d8 100644 --- a/lib/ansible/plugins/connection/paramiko_ssh.py +++ b/lib/ansible/plugins/connection/paramiko_ssh.py @@ -151,11 +151,13 @@ class Connection(ConnectionBase): self.keyfile = os.path.expanduser("~/.ssh/known_hosts") if C.HOST_KEY_CHECKING: - try: - #TODO: check if we need to look at several possible locations, possible for loop - ssh.load_system_host_keys("/etc/ssh/ssh_known_hosts") - except IOError: - pass # file was not found, but not required to function + for ssh_known_hosts in ("/etc/ssh/ssh_known_hosts", "/etc/openssh/ssh_known_hosts"): + try: + #TODO: check if we need to look at several possible locations, possible for loop + ssh.load_system_host_keys(ssh_known_hosts) + break + except IOError: + pass # file was not found, but not required to function ssh.load_system_host_keys() ssh.set_missing_host_key_policy(MyAddPolicy(self._new_stdin, self))