Skip to content

Instantly share code, notes, and snippets.

@adamcrews
Created April 1, 2014 18:52
Show Gist options
  • Save adamcrews/9920571 to your computer and use it in GitHub Desktop.
Save adamcrews/9920571 to your computer and use it in GitHub Desktop.
auth_keys
class profile::ssh {
# this installs ssh server, makes it start, ect.
# my current favorite is https://forge.puppetlabs.com/saz/ssh
include ssh
}
define myssh::authkeys_file (
$user = root,
$group = root,
$keygroup = 'default',
) {
# $name is set to whatever we call this define as.
# so usage is myssh::authkeys_file { '/root': keygroup => 'cluster' }
$homedir = $name
file { "${homedir}/.ssh":
ensure => directory,
mode => '0700',
owner => $user,
group => $group,
}
file { "${homedir}/.ssh/authorized_keys":
ensure => file,
mode => '0600',
owner => $user,
group => $group,
source => "puppet:///modules/${module_name}/authorized_keys.${keygroup}"
}
}
node /*.int.domain.de$/ {
include profile::ssh
myssh::authkeys_file { '/root':
keygroup => 'cluster',
}
}
# this is more specific than the regex, so it matches this host instead of the regex
node 'bob.int.domain.de' {
include profile::ssh
myssh::authkeys_file { '/root':
keygroup => 'special',
}
}
node 'workstation.adam.vm' {
include profile::ssh
myssh::authkeys_file { '/home/adam':
keygroup => default,
owner => 'adam',
group => 'adam',
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment