From fa1331e4a7fccb103d50fac3aa70ee3c8638c615 Mon Sep 17 00:00:00 2001
From: Clark Boylan <clark.boylan@gmail.com>
Date: Mon, 12 Sep 2022 12:55:24 -0700
Subject: [PATCH] Remove redundant ssh known hosts prep

This removes redundant ssh known hosts prep in the
multi-node-known-hosts role as we've seen these tasks take significant
amounts of time due to the high cost of ansible looping. According to
the change [0] that added the system wide known_hosts setting this was
not originally done to avoid breaking testing in openstack-zuul-jobs.
Since then those tests have been moved to zuul-jobs [1] and I've updated
them with this change.

This should cut the time to run this role by about half.

[0] https://review.opendev.org/c/zuul/zuul-jobs/+/548642
[1] https://review.opendev.org/c/zuul/zuul-jobs/+/668767

Change-Id: I90492bbb5ae15fd3b36a54071c4eef891f53b405
---
 roles/multi-node-known-hosts/tasks/main.yaml         | 8 --------
 test-playbooks/multinode/multi-node-known-hosts.yaml | 2 +-
 2 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/roles/multi-node-known-hosts/tasks/main.yaml b/roles/multi-node-known-hosts/tasks/main.yaml
index 077431b40..4f7b7cf8b 100644
--- a/roles/multi-node-known-hosts/tasks/main.yaml
+++ b/roles/multi-node-known-hosts/tasks/main.yaml
@@ -2,14 +2,6 @@
   generate_all_known_hosts:
     hostvars: "{{ hostvars }}"
 
-- name: add known_host record for every public key of every other ip, hostname for ansible_user
-  known_hosts:
-    name: "{{ zj_known_host.name }}"
-    key: "{{ zj_known_host.key }}"
-  with_items: "{{ ansible_facts.all_known_hosts }}"
-  loop_control:
-    loop_var: zj_known_host
-
 - name: add default known_host record for every user
   become: true
   known_hosts:
diff --git a/test-playbooks/multinode/multi-node-known-hosts.yaml b/test-playbooks/multinode/multi-node-known-hosts.yaml
index 197bdffc2..cc19aa6bc 100644
--- a/test-playbooks/multinode/multi-node-known-hosts.yaml
+++ b/test-playbooks/multinode/multi-node-known-hosts.yaml
@@ -4,7 +4,7 @@
     - multi-node-known-hosts
   post_tasks:
     - name: lookup known_hosts file
-      command: cat ~/.ssh/known_hosts
+      command: cat /etc/ssh/ssh_known_hosts
       register: known_hosts
 
     - name: Set up host addresses