zuul-jobs/test-playbooks/multinode/multi-node-known-hosts.yaml
Clark Boylan fa1331e4a7 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
2022-09-12 12:55:24 -07:00

32 lines
1.1 KiB
YAML

- name: Test the multi-node-known-hosts role
hosts: all
roles:
- multi-node-known-hosts
post_tasks:
- name: lookup known_hosts file
command: cat /etc/ssh/ssh_known_hosts
register: known_hosts
- name: Set up host addresses
set_fact:
host_addresses: >
{% set hosts = [] -%}
{% for host, vars in hostvars.items() -%}
{% if vars['nodepool']['private_ipv4'] | length > 0 -%}
{% set _ = hosts.append(vars['nodepool']['private_ipv4']) -%}
{% endif -%}
{% if vars['nodepool']['public_ipv4'] | length > 0 -%}
{% set _ = hosts.append(vars['nodepool']['public_ipv4']) -%}
{% endif -%}
{% if vars['nodepool']['public_ipv6'] | length > 0 -%}
{% set _ = hosts.append(vars['nodepool']['public_ipv6']) -%}
{% endif -%}
{% endfor -%}
{{- hosts | sort | unique -}}
- name: assert that hosts are in known_hosts
assert:
that:
- "item in known_hosts.stdout"
with_items: "{{ host_addresses }}"