zuul-jobs/roles/multi-node-known-hosts/tasks/main.yaml
Monty Taylor 054812719f
Scope all_known_hosts in mult-node-known-hosts
Ansible is moving towards ansible_facts return values going in to
ansible_facts rather than the top-level dict. ansible_facts exists
starting in ansible 2.5, so go ahead and start consuming the value that
way.

Change-Id: Iac13b1efb47c9d79ed088e1cf9176003790c74f7
2018-07-23 13:21:39 -05:00

18 lines
532 B
YAML

- name: Get known_hosts facts
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: "{{ item.name }}"
key: "{{ item.key }}"
with_items: "{{ ansible_facts.all_known_hosts }}"
- name: add default known_host record for every user
become: true
known_hosts:
name: "{{ item.name }}"
key: "{{ item.key }}"
path: /etc/ssh/ssh_known_hosts
with_items: "{{ ansible_facts.all_known_hosts }}"