Improve SSH known host error messages

A common failure early on when using Kayobe is during discovery of SSH
known hosts. This happens if a host does not have an IP address
configured on the admin (SSH) network. The failure looks like this:

PLAY [Ensure known hosts are configured]
**********************************************************************
TASK [ssh-known-host : Scan for SSH keys]
**********************************************************************
failed: [compute0 -> localhost] (item=) => {"ansible_loop_var": "item",
    "changed": false, "cmd": ["ssh-keyscan"], "delta": "0:00:00.013855",
    "end": "2020-04-17 10:51:01.857855", "item": "", "msg": "non-zero
        return code", "rc": 1, "start": "2020-04-17 10:51:01.844000",
    "stderr": "usage: ssh-keyscan [-46cDHv] [-f file] [-p port] [-T
        timeout] [-t type]\n\t\t   [host | addrlist namelist]",
    "stderr_lines": ["u sage: ssh-keyscan [-46cDHv] [-f file] [-p port]
        [-T timeout] [-t type]", "\t\t   [host | addrlist namelist]"],
        "stdout": "", "stdout_lines": []}

This happens when ansible_host is an empty string, typically because the
host has no IP address defined in for the admin network in
network-allocation.yml. This is very confusing for a new user. We should
provide a more informative message.

It's not exactly clear how a user gets to this point, since the
ip-allocation.yml playbook runs before ssh-known-host.yml, which should
populate network-allocation.yml.

This change detects this failure mode and provides a message with
information about how to resolve it.

Change-Id: I564b6e4509a30dec7c49a23bb2f75d490be775ed
Story: 2007566
Task: 39456
This commit is contained in:
Mark Goddard 2020-04-17 11:59:16 +01:00
parent e0932bd788
commit 7890914627
2 changed files with 20 additions and 0 deletions

View File

@ -1,4 +1,18 @@
--- ---
# If no IP address has been configured for the host on the admin network, this
# is typically the first task to fail. Provide a friendly message with
# information on how to resolve the issue.
- name: Validate SSH address
fail:
msg: >-
Host {{ inventory_hostname }} has no address configured on the admin
network. IP addresses may be manually configured in
'network-allocations.yml', or are automatically allocated during the
following commands: 'kayobe seed hypervisor host configure', 'kayobe
seed host configure', 'kayobe overcloud host configure', 'kayobe seed
vm provision' and 'kayobe overcloud inventory discover'.
when: not ansible_host | default(inventory_hostname)
- name: Scan for SSH keys - name: Scan for SSH keys
local_action: local_action:
module: command ssh-keyscan {{ item }} module: command ssh-keyscan {{ item }}

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Improves error message seen when discovering SSH known hosts for a host
without an IP address defined in
``${KAYOBE_CONFIG_PATH}/network-allocation.yml``.