Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Remove non-template mode from tripleo-ssh-known-hosts role
Browse files Browse the repository at this point in the history
Once tripleo-heat-templates is migrated to use the template mode of the
tripleo-ssh-known-hosts role, the old mode that used the ssh_known_hosts
variable as input can be removed.

Since the non-namespaced var (ssh_known_hosts) is no longer used, the
entire molecule/legacy_vars dir is also removed.

Depends-On: I10d0de42acc0b88b7947b464e976b5d0b9067ca2
Change-Id: I4a2002fa42337e115f9679fcf2f2db71308389d6
  • Loading branch information
slagle authored and sshnaidm committed Jul 14, 2019
1 parent 6f43506 commit 6362ae8
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 219 deletions.
6 changes: 0 additions & 6 deletions tripleo_ansible/roles/tripleo-ssh-known-hosts/README.md
Expand Up @@ -9,12 +9,6 @@ Requirements

This section needs to be documented.

Role variables
--------------

- ssh_known_hosts: -- Dict of hostname to ssh_known_hosts entries for a given
host

Dependencies
------------

Expand Down
19 changes: 0 additions & 19 deletions tripleo_ansible/roles/tripleo-ssh-known-hosts/defaults/main.yml
Expand Up @@ -16,22 +16,3 @@


# All variables intended for modification should place placed in this file.

# NOTE(cloudnull): This role used to use a non-namespaced option, which has a high
# probability of creating conflicts with other roles in the greater
# ansible ecosystem. To ensure that we're able to retain existing
# variable functionality the "ssh_known_hosts" option will supersede
# "tripleo_ssh_known_hosts" if defined. This default should be removed
# just as soon as we're validate that the non-namespaced option is
# no longer in use.
#
# tripleo_ssh_known_hosts:
# overcloud-controller-0: '[172.17.25.246]*,[overcloud-controller-0.localdomain]*,[overcloud-controller-0]*,...'
# overcloud-novacompute-0: '[172.17.25.247]*,[overcloud-novacompute-0.localdomain]*,[overcloud-novacompute-0]*,...'
# overcloud-novacompute-1: '[172.17.25.248]*,[overcloud-novacompute-1.localdomain]*,[overcloud-novacompute-1]*,...'
# overcloud-novacompute-2: '[172.17.25.249]*,[overcloud-novacompute-2.localdomain]*,[overcloud-novacompute-2]*,...'
#
# tripleo_ssh_known_hosts_use_template: false

tripleo_ssh_known_hosts: "{{ ssh_known_hosts | default({}) }}"
tripleo_ssh_known_hosts_use_template: false
Expand Up @@ -30,9 +30,10 @@ provisioner:
hosts:
all:
vars:
tripleo_ssh_known_hosts:
"centos7": '[10.0.0.0]*,[test-0.localdomain]*,[test-0]*'
"fedora28": '[10.0.0.0]*,[test-0.localdomain]*,[test-0]*'
ctlplane_ip: 10.0.0.0
cloud_domain: localdomain
enabled_networks: []
role_networks: []
children:
overcloud:
hosts:
Expand Down
Expand Up @@ -24,5 +24,6 @@


def test_host_key_add(host):
assert '[10.0.0.0]*,[test-0.localdomain]*,[test-0]* ssh-rsa AAAATEST' \
in host.file("/etc/ssh/ssh_known_hosts").content_string
hostname = host.ansible.get_variables()['inventory_hostname']
line = '[10.0.0.0]*,[%s.localdomain]*,[%s]* ssh-rsa AAAATEST' % (hostname, hostname)
assert line in host.file("/etc/ssh/ssh_known_hosts").content_string

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

15 changes: 1 addition & 14 deletions tripleo_ansible/roles/tripleo-ssh-known-hosts/tasks/main.yml
Expand Up @@ -57,26 +57,13 @@
{%- endfor -%}
{{ ' ssh-rsa ' ~ hostvars[host]['ansible_ssh_host_key_rsa_public'] }}
{% endfor %}
when:
- tripleo_ssh_known_hosts_use_template | bool
- name: Add host keys to temporary ssh_known_hosts from rendered template
- name: Add host keys to temporary ssh_known_hosts
lineinfile:
path: "{{ ssh_known_hosts_tmp.path }}"
line: "{{ item }}"
create: true
with_items: "{{ ssh_known_hosts_lines.splitlines() }}"
when:
- tripleo_ssh_known_hosts_use_template | bool

- name: Add host keys to temporary ssh_known_hosts
lineinfile:
path: "{{ ssh_known_hosts_tmp.path }}"
line: "{{ tripleo_ssh_known_hosts[(hostvars[item]['ansible_hostname'] | lower)] ~ ' ssh-rsa ' ~ hostvars[item]['ansible_ssh_host_key_rsa_public'] }}"
create: true
with_items: "{{ groups['overcloud'] | intersect(play_hosts) }}"
when:
- not (tripleo_ssh_known_hosts_use_template | bool)

# Workaround https://bugs.launchpad.net/tripleo/+bug/1810932
# Ansible modules perform a replace instead of in-place modification.
Expand Down

0 comments on commit 6362ae8

Please sign in to comment.