Skip to content

Instantly share code, notes, and snippets.

@seidler2547
Created April 16, 2020 08:37
Show Gist options
  • Save seidler2547/e390b186a6ac4d5ca7b767971d18f36c to your computer and use it in GitHub Desktop.
Save seidler2547/e390b186a6ac4d5ca7b767971d18f36c to your computer and use it in GitHub Desktop.
Exchange SSH user and host keys using Puppet
class mybase::jenkins::master {
Sshkey <<| tag == 'jenkinsslave' |>>
}
# using https://forge.puppet.com/jtopjian/sshkeys
class mybase::jenkins::slave($allowed_users = []) {
@@sshkey { $fqdn:
ensure => present,
type => "rsa",
key => $sshrsakey,
tag => 'jenkinsslave',
}
ensure_resource('mybase::jenkins::slave::user', $allowed_users, {})
}
define mybase::jenkins::slave::user($remoteuser = 'jenkins', $remotehost = 'jenkins.example.com') {
sshkeys::set_authorized_key { "allow $remoteuser as $title":
local_user => $title,
remote_user => "$remoteuser@$remotehost",
}
}
@seidler2547
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment