Files
tripleo-heat-templates/extraconfig/tasks/ssh/known_hosts_config.yaml
Alex Schultz 7c97320334 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
2018-05-21 14:32:49 +00:00

43 lines
1.1 KiB
YAML

heat_template_version: rocky
description: 'SSH Known Hosts Config'
parameters:
known_hosts:
type: string
resources:
SSHKnownHostsConfig:
type: OS::Heat::SoftwareConfig
properties:
group: script
config: |
str_replace:
params:
KNOWN_HOSTS: {get_param: known_hosts}
template: |
#!/bin/bash
set -eux
set -o pipefail
echo "Creating ssh known hosts file"
if [ -d /etc/ssh/ssh_known_hosts ]; then
rm -rf /etc/ssh/ssh_known_hosts
fi
cat <<EOF | grep -v '^$' >/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}