Skip to content

Instantly share code, notes, and snippets.

@Ancillas
Created January 18, 2013 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ancillas/4568142 to your computer and use it in GitHub Desktop.
Save Ancillas/4568142 to your computer and use it in GitHub Desktop.
A very simple Puppet example of setting the authorized_keys, id_rsa, and sudoers file for passwordless sudo access.
node default {
class {'passwordlessroot':
publickey => "public",
privatekey => "private",
}
}
class passwordlessroot(
$publickey,
$privatekey
){
file { 'privatekey':
path => '/root/.ssh/id_rsa',
ensure => 'present',
mode => '0400',
owner => 'root',
group => 'root',
content => "$privatekey",
}
file { 'publickey':
path => '/root/.ssh/authorized_keys',
ensure => 'present',
mode => '0600',
owner => 'root',
group => 'root',
content => "$publickey",
}
file { 'sudoers':
path => '/etc/sudoers',
ensure => 'present',
mode => '0600',
owner => 'root',
group => 'root',
content => 'puppet:///path/to/your/sudoers/file',
}
# Your sudoers template really only needs one line added, or replaced (if an entry for root already exists)
# root ALL=(ALL) NOPASSWD: ALL
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment