From 482f2eb2f736e8d5d01a775dae160f819240d708 Mon Sep 17 00:00:00 2001 From: Alex Schultz Date: Fri, 18 May 2018 21:07:27 -0600 Subject: [PATCH] Use str_replace for known_hosts There is a limit to how long input data can be for the heat script hook. It turns out that data longer than 131072, will return an Argument list to long error. To get around this, we need to pass this data in a different way so that the heat script hook will work. NOTE: Includes fix from If7a4c6f3581bed270f478b98b8da8fe010acbbc1 Change-Id: Ie3bd17ca9863e7687721e8c2628e485ea1849321 Closes-Bug: #1772071 (cherry picked from commit 7c973203345dbcf5ef94a5bcad2b089f5298c9b0) --- extraconfig/tasks/ssh/known_hosts_config.yaml | 40 +++++++++++-------- overcloud.j2.yaml | 1 + 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/extraconfig/tasks/ssh/known_hosts_config.yaml b/extraconfig/tasks/ssh/known_hosts_config.yaml index 2bd80e7b05..5dc164a6d2 100644 --- a/extraconfig/tasks/ssh/known_hosts_config.yaml +++ b/extraconfig/tasks/ssh/known_hosts_config.yaml @@ -11,26 +11,32 @@ resources: type: OS::Heat::SoftwareConfig properties: group: script - inputs: - - name: known_hosts - default: {get_param: known_hosts} - config: | - #!/bin/bash - set -eux - set -o pipefail + config: + str_replace: + params: + KNOWN_HOSTS: {get_param: known_hosts} + template: | + #!/bin/bash + set -eux + set -o pipefail - echo "Creating ssh known hosts file" + echo "Creating ssh known hosts file" - if [ ! -z "${known_hosts}" ]; then - echo "${known_hosts}" - echo -ne "${known_hosts}" > /etc/ssh/ssh_known_hosts - chmod 0644 /etc/ssh/ssh_known_hosts - else - rm -f /etc/ssh/ssh_known_hosts - echo "No ssh known hosts" - fi + if [ -d /etc/ssh/ssh_known_hosts ]; then + rm -rf /etc/ssh/ssh_known_hosts + fi + cat </etc/ssh/ssh_known_hosts + KNOWN_HOSTS + EOF + if [ ! -s /etc/ssh/ssh_known_hosts ]; then + echo "No known hosts" + rm -f /etc/ssh/ssh_known_hosts + else + echo "$(cat /etc/ssh/ssh_known_hosts | wc -l) known hosts" + chmod 0644 /etc/ssh/ssh_known_hosts + fi outputs: OS::stack_id: description: The SSHKnownHostsConfig resource. - value: {get_resource: SSHKnownHostsConfig} \ No newline at end of file + value: {get_resource: SSHKnownHostsConfig} diff --git a/overcloud.j2.yaml b/overcloud.j2.yaml index 828b6febbd..abcdd8f1b5 100644 --- a/overcloud.j2.yaml +++ b/overcloud.j2.yaml @@ -478,6 +478,7 @@ resources: depends_on: {% for role_inner in roles %} - {{role_inner.name}}HostsDeployment + - {{role_inner.name}}SshKnownHostsDeployment {% endfor %} properties: name: {{role.name}}AllNodesDeployment