annotate modules/ssh/manifests/config_entry.pp @ 385:d9009f54eb23

Migrate to a fully-fledged SSH module This handles lots of the server path differences for us
author IBBoard <dev@ibboard.co.uk>
date Mon, 03 Jan 2022 17:05:54 +0000
parents
children adf6fe9bbc17
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
385
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
1 # == Define: ssh::config_entry
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
2 #
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
3 # Manage an entry in ~/.ssh/config for a particular user. Lines model the lines
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
4 # in each Host block.
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
5 define ssh::config_entry (
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
6 $owner,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
7 $group,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
8 $path,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
9 $host,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
10 $order = '10',
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 $ensure = 'present',
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
12 $lines = [],
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
13 ) {
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
14
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
15 # All lines including the host line. This will be joined with "\n " for
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
16 # indentation.
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
17 $entry = concat(["Host ${host}"], $lines)
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
18 $content = join($entry, "\n")
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
19
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
20 if ! defined(Concat[$path]) {
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
21 concat { $path:
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
22 ensure => present,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
23 owner => $owner,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
24 group => $group,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
25 mode => '0644',
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
26 ensure_newline => true,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 }
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
28 }
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
29
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
30 concat::fragment { "${path} Host ${host}":
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
31 target => $path,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
32 content => $content,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
33 order => $order,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
34 tag => "${owner}_ssh_config",
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
35 }
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
36 }