Merge "Use ansible_facts in tripleo_ssh_known_hosts role"

This commit is contained in:
Zuul 2021-04-14 18:46:46 +00:00 committed by Gerrit Code Review
commit 4cf8112b26
5 changed files with 8 additions and 4 deletions

View File

@ -18,5 +18,8 @@
- name: Converge - name: Converge
hosts: all hosts: all
pre_tasks: pre_tasks:
- name: Override ssh_host_key_rsa_public test value in ansible_facts
set_fact:
ansible_facts: "{{ ansible_facts|combine({'ssh_host_key_rsa_public': 'AAAATEST'}) }}"
roles: roles:
- role: "tripleo_ssh_known_hosts" - role: "tripleo_ssh_known_hosts"

View File

@ -35,7 +35,6 @@ provisioner:
allovercloud: allovercloud:
hosts: hosts:
ubi8: ubi8:
ansible_ssh_host_key_rsa_public: AAAATEST
ctlplane_ip: 10.0.0.1 ctlplane_ip: 10.0.0.1
ctlplane_hostname: ubi8.ctlplane.localdomain ctlplane_hostname: ubi8.ctlplane.localdomain
internal_api_ip: 10.0.1.1 internal_api_ip: 10.0.1.1

View File

@ -18,5 +18,8 @@
- name: Converge - name: Converge
hosts: all hosts: all
pre_tasks: pre_tasks:
- name: Override ssh_host_key_rsa_public test value in ansible_facts
set_fact:
ansible_facts: "{{ ansible_facts|combine({'ssh_host_key_rsa_public': 'AAAATEST'}) }}"
roles: roles:
- role: "tripleo_ssh_known_hosts" - role: "tripleo_ssh_known_hosts"

View File

@ -35,7 +35,6 @@ provisioner:
allovercloud: allovercloud:
hosts: hosts:
ubi8: ubi8:
ansible_ssh_host_key_rsa_public: AAAATEST
log: true log: true
env: env:
ANSIBLE_STDOUT_CALLBACK: yaml ANSIBLE_STDOUT_CALLBACK: yaml

View File

@ -49,7 +49,7 @@
ssh_known_hosts_lines: |- ssh_known_hosts_lines: |-
{% for host in groups['allovercloud'] | intersect(play_hosts) %} {% for host in groups['allovercloud'] | intersect(play_hosts) %}
{% set hostdata = hostvars[host] %} {% set hostdata = hostvars[host] %}
{% if 'ansible_ssh_host_key_rsa_public' in hostdata %} {% if 'ssh_host_key_rsa_public' in hostdata['ansible_facts'] %}
{% set entries = [] %} {% set entries = [] %}
{% set enabled_host_networks = hostdata['tripleo_role_networks']|default([]) %} {% set enabled_host_networks = hostdata['tripleo_role_networks']|default([]) %}
{% for network in enabled_host_networks %} {% for network in enabled_host_networks %}
@ -64,7 +64,7 @@
{% set _ = entries.append('[' ~ hostdata['canonical_hostname'] ~ ']*') %} {% set _ = entries.append('[' ~ hostdata['canonical_hostname'] ~ ']*') %}
{% endif %} {% endif %}
{% set _ = entries.append('[' ~ host ~ ']*') %} {% set _ = entries.append('[' ~ host ~ ']*') %}
{% set line = entries|unique|join(',') ~ ' ssh-rsa ' ~ hostdata['ansible_ssh_host_key_rsa_public'] %} {% set line = entries|unique|join(',') ~ ' ssh-rsa ' ~ hostdata['ansible_facts']['ssh_host_key_rsa_public'] %}
{{ line }} {{ line }}
{% endif %} {% endif %}
{% endfor %} {% endfor %}