annotate modules/ssh/manifests/config_entry.pp @ 482:d83de9b3a62b default tip

Update hiera.yaml within Puppet config Forgot that we manage it from here. Now has content to match new packages
author IBBoard <dev@ibboard.co.uk>
date Fri, 30 Aug 2024 16:10:36 +0100
parents adf6fe9bbc17
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
478
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
1 # @summary Create config entries in a users' ~/.ssh/config
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
2 #
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
3 # Manage an entry in ~/.ssh/config for a particular user. Lines model the
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
4 # lines in each Host block.
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
5 #
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
6 # @param ensure
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
7 # ensure attribute for entry.
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
8 #
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
9 # @param group
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
10 # User group used for the generated ssh/config file.
385
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
11 #
478
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
12 # @param host
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
13 # Host this generated ssh/config file is used for.
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
14 #
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
15 # @param lines
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
16 # Lines to be added tp ssh/config file.
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
17 #
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
18 # @param order
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
19 # Order of entries in the ssh/config file used for concatenation.
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
20 #
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
21 # @param owner
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
22 # User/Owner used for the generated ssh/config file.
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
23 #
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
24 # @param path
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
25 # Absolute path used for the generated ssh/config file.
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
26 #
385
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
27 define ssh::config_entry (
478
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
28 String[1] $owner,
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
29 String[1] $group,
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
30 Stdlib::Absolutepath $path,
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
31 String[1] $host,
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
32 Enum['present','absent'] $ensure = 'present',
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
33 Integer[0] $order = 10,
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
34 Array[String] $lines = [],
385
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
478
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
37 # All lines including the host line. This will be joined with "\n " for
385
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
38 # indentation.
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
39 $entry = concat(["Host ${host}"], $lines)
478
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
40 $content = join($entry, "\n ")
385
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
41
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
42 if ! defined(Concat[$path]) {
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
43 concat { $path:
478
adf6fe9bbc17 Update Puppet modules to latest versions
IBBoard <dev@ibboard.co.uk>
parents: 385
diff changeset
44 ensure => $ensure,
385
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
45 owner => $owner,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
46 group => $group,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
47 mode => '0644',
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
48 ensure_newline => true,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
49 }
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
50 }
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
51
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
52 concat::fragment { "${path} Host ${host}":
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
53 target => $path,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
54 content => $content,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
55 order => $order,
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
56 tag => "${owner}_ssh_config",
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
57 }
d9009f54eb23 Migrate to a fully-fledged SSH module
IBBoard <dev@ibboard.co.uk>
parents:
diff changeset
58 }