Puppet Function: ssh::known_hosts

Defined in:
modules/ssh/functions/known_hosts.pp
Function type:
Puppet Language

Overview

ssh::known_hosts(Boolean $include_hostnames = true)Any

SPDX-License-Identifier: Apache-2.0

Parameters:

  • include_hostnames (Boolean) (defaults to: true)

Returns:

  • (Any)


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
# File 'modules/ssh/functions/known_hosts.pp', line 2

function ssh::known_hosts (
    Boolean $include_hostnames = true,

) {
    $pql = @("PQL")
    resources[parameters, title] {
        type = 'Sshkey' and exported = true and parameters.ensure = 'present' order by title
    }
    | PQL
    Hash(wmflib::puppetdb_query($pql).map |$resource| {
        $key = $resource['name'].lest || { $resource['title'] }

        if $include_hostnames {
            $params =  $resource['parameters']
        } else {
            $aliases = 'host_aliases' in $resource['parameters'] ? {
                # filter out anything with out dots or colons
                true  => $resource['parameters']['host_aliases'].filter |$alias| { $alias =~ /[\.:]/ },
                false => [],
            }
            $params = $resource['parameters'] + {'host_aliases' => $aliases }
        }
        [$key, $params]
    })
}