Merge "Use str_replace for known_hosts"

This commit is contained in:
Zuul
2018-05-22 02:35:32 +00:00
committed by Gerrit Code Review
2 changed files with 23 additions and 16 deletions

View File

@@ -11,26 +11,32 @@ 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: |
#!/bin/bash str_replace:
set -eux params:
set -o pipefail 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 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
rm -f /etc/ssh/ssh_known_hosts EOF
echo "No ssh known hosts" if [ ! -s /etc/ssh/ssh_known_hosts ]; then
fi 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: outputs:
OS::stack_id: OS::stack_id:
description: The SSHKnownHostsConfig resource. description: The SSHKnownHostsConfig resource.
value: {get_resource: SSHKnownHostsConfig} value: {get_resource: SSHKnownHostsConfig}

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