Add ssh::config_entry defined type
This patch adds a mechanism to manage ~/.ssh/config entries using the concat module.
This commit is contained in:
parent
2a26ad43f3
commit
68dd872428
30
README.md
30
README.md
@ -8,6 +8,9 @@ ssh_key_ensure and purge_keys.
|
|||||||
|
|
||||||
This module may be used with a simple `include ::ssh`
|
This module may be used with a simple `include ::ssh`
|
||||||
|
|
||||||
|
The `ssh::config_entry` defined type may be used directly and is used to manage
|
||||||
|
Host entries in a personal `~/.ssh/config` file.
|
||||||
|
|
||||||
===
|
===
|
||||||
|
|
||||||
### Table of Contents
|
### Table of Contents
|
||||||
@ -852,3 +855,30 @@ ssh::keys:
|
|||||||
ensure: absent
|
ensure: absent
|
||||||
user: root
|
user: root
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Manage config entries in a personal ssh/config file.
|
||||||
|
|
||||||
|
```
|
||||||
|
Ssh::Config_entry {
|
||||||
|
ensure => present,
|
||||||
|
path => '/home/jenkins/.ssh/config',
|
||||||
|
owner => 'jenkins',
|
||||||
|
group => 'jenkins',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ssh::config_entry { 'jenkins *':
|
||||||
|
host => '*',
|
||||||
|
lines => [
|
||||||
|
' ForwardX11 no',
|
||||||
|
' StrictHostKeyChecking no',
|
||||||
|
],
|
||||||
|
order => '10',
|
||||||
|
}
|
||||||
|
|
||||||
|
ssh::config_entry { 'jenkins github.com':
|
||||||
|
host => 'github.com',
|
||||||
|
lines => [" IdentityFile /home/jenkins/.ssh/jenkins-gihub.key"],
|
||||||
|
order => '20',
|
||||||
|
}
|
||||||
|
```
|
||||||
|
36
manifests/config_entry.pp
Normal file
36
manifests/config_entry.pp
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# == Define: ssh::config_entry
|
||||||
|
#
|
||||||
|
# Manage an entry in ~/.ssh/config for a particular user. Lines model the lines
|
||||||
|
# in each Host block.
|
||||||
|
define ssh::config_entry (
|
||||||
|
$owner,
|
||||||
|
$group,
|
||||||
|
$path,
|
||||||
|
$host,
|
||||||
|
$order = '10',
|
||||||
|
$ensure = 'present',
|
||||||
|
$lines = [],
|
||||||
|
) {
|
||||||
|
|
||||||
|
# All lines including the host line. This will be joined with "\n " for
|
||||||
|
# indentation.
|
||||||
|
$entry = concat(["Host ${host}"], $lines)
|
||||||
|
$content = join($entry, "\n")
|
||||||
|
|
||||||
|
if ! defined(Concat[$path]) {
|
||||||
|
concat { $path:
|
||||||
|
ensure => present,
|
||||||
|
owner => $owner,
|
||||||
|
group => $group,
|
||||||
|
mode => '0644',
|
||||||
|
ensure_newline => true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
concat::fragment { "${path} Host ${host}":
|
||||||
|
target => $path,
|
||||||
|
content => $content,
|
||||||
|
order => $order,
|
||||||
|
tag => "${owner}_ssh_config",
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user