Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

puppet: Allow controlling known_hosts.

Alex Vandiveraaf3eb514db5
diff --git a/puppet/zulip_ops/manifests/user_dotfiles.pp b/puppet/zulip_ops/manifests/user_dotfiles.pp
index 7ec15081b01..928be059034 100644
--- a/puppet/zulip_ops/manifests/user_dotfiles.pp
+++ b/puppet/zulip_ops/manifests/user_dotfiles.pp
@@ -2,6 +2,7 @@ define zulip_ops::user_dotfiles (
$home = '',
$keys = false,
$authorized_keys = false,
+ $known_hosts = false,
) {
$user = $name
@@ -52,4 +53,22 @@ define zulip_ops::user_dotfiles (
require => File["${homedir}/.ssh"],
}
}
+ if $known_hosts != false {
+ file { "${homedir}/.ssh/known_hosts":
+ # We mark this as "present" to ensure that it exists, but not to
+ # directly control its contents.
+ ensure => present,
+ owner => $user,
+ group => $user,
+ mode => '0644',
+ require => File["${homedir}/.ssh"],
+ }
+ $known_hosts.each |String $hostname| {
+ exec { "${user} ssh known_hosts ${hostname}":
+ command => "ssh-keyscan ${hostname} >> ${homedir}/.ssh/known_hosts",
+ unless => "grep ${hostname} ${homedir}/.ssh/known_hosts",
+ require => File["${homedir}/.ssh/known_hosts"],
+ }
+ }
+ }
}