aboutsummaryrefslogtreecommitdiffstats
path: root/extraconfig/tasks/ssh/known_hosts_config.yaml
blob: 2ebcb63c3ea02809894e584103a07038ab3ebe0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
heat_template_version: ocata
description: 'SSH Known Hosts Config'

parameters:
  known_hosts:
    type: string

resources:

  SSHKnownHostsConfig:
    type: OS::Heat::SoftwareConfig
    properties:
      group: script
      inputs:
        - name: known_hosts
          default: {get_param: known_hosts}
      config: |
        #!/bin/bash
        set -eux
        set -o pipefail

        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

outputs:
  OS::stack_id:
    description: The SSHKnownHostsConfig resource.
    value: {get_resource: SSHKnownHostsConfig}