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.

Change-Id: Ie3bd17ca9863e7687721e8c2628e485ea1849321
Closes-Bug: #1772071
This commit is contained in:
Alex Schultz 2018-05-18 21:07:27 -06:00
parent 51f9c5c52e
commit 7c97320334
2 changed files with 23 additions and 16 deletions

View File

@ -11,23 +11,29 @@ resources:
type: OS::Heat::SoftwareConfig type: OS::Heat::SoftwareConfig
properties: properties:
group: script group: script
inputs:
- name: known_hosts
default: {get_param: known_hosts}
config: | config: |
str_replace:
params:
KNOWN_HOSTS: {get_param: known_hosts}
template: |
#!/bin/bash #!/bin/bash
set -eux set -eux
set -o pipefail set -o pipefail
echo "Creating ssh known hosts file" echo "Creating ssh known hosts file"
if [ ! -z "${known_hosts}" ]; then if [ -d /etc/ssh/ssh_known_hosts ]; then
echo "${known_hosts}" rm -rf /etc/ssh/ssh_known_hosts
echo -ne "${known_hosts}" > /etc/ssh/ssh_known_hosts fi
chmod 0644 /etc/ssh/ssh_known_hosts cat <<EOF | grep -v '^$' >/etc/ssh/ssh_known_hosts
else KNOWN_HOSTS
EOF
if [ ! -s /etc/ssh/ssh_known_hosts ]; then
echo "No known hosts"
rm -f /etc/ssh/ssh_known_hosts rm -f /etc/ssh/ssh_known_hosts
echo "No ssh known hosts" else
echo "$(cat /etc/ssh/ssh_known_hosts | wc -l) known hosts"
chmod 0644 /etc/ssh/ssh_known_hosts
fi fi
outputs: outputs:

View File

@ -488,6 +488,7 @@ resources:
depends_on: depends_on:
{% for role_inner in roles %} {% for role_inner in roles %}
- {{role_inner.name}}HostsDeployment - {{role_inner.name}}HostsDeployment
- {{role_inner.name}}SshKnownHostsDeployment
{% endfor %} {% endfor %}
properties: properties:
name: {{role.name}}AllNodesDeployment name: {{role.name}}AllNodesDeployment