From 14f5f960f9815001b426ec37a067c65fdb15084f Mon Sep 17 00:00:00 2001
From: Maarten de Waard <maarten@greenhost.nl>
Date: Fri, 30 Aug 2019 14:16:15 +0200
Subject: [PATCH] make no host key checking an ssh-extra-arg

---
 openappstack/ansible.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/openappstack/ansible.py b/openappstack/ansible.py
index 4bcdef229..aa2f9b0b9 100644
--- a/openappstack/ansible.py
+++ b/openappstack/ansible.py
@@ -22,6 +22,8 @@ def run_ansible(clus, playbook, ansible_params=None, no_host_key_checking=False)
         params.  Each inner list may only contain one element. Can be directly
         forwarded from argparse. Example:
         `ansible_params = [[become-user=root], [verbose]]`
+    :param bool no_host_key_checking: turns off "strict host key checking" on
+        the SSH connection (NOTE: UNSAFE!)
     """
     # playbook path here is relative to private_data_dir/project, see
     # https://ansible-runner.readthedocs.io/en/latest/intro.html#inputdir
@@ -35,8 +37,9 @@ def run_ansible(clus, playbook, ansible_params=None, no_host_key_checking=False)
             param = param[0]
             ansible_playbook_command.append(' --' + param)
     if no_host_key_checking:
-        ansible_playbook_command += ['-o', 'StrictHostKeyChecking=no', '-o',
-                                     'UserKnownHostsFile=/dev/null']
+        ansible_playbook_command += [
+            '--ssh-extra-args',
+            '-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null']
 
     ansible_playbook_command += \
         ['-i', clus.inventory_file, '-e', '@' + clus.settings_file, playbook]
-- 
GitLab