Created
November 14, 2012 20:32
-
-
Save n8foo/4074588 to your computer and use it in GitHub Desktop.
puppet user.pp example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define add_user ( $email, $uid, $name, $key) { | |
$username = $title | |
user { $username: | |
comment => "$name,$email", | |
home => "/home/$username", | |
shell => "/bin/bash", | |
uid => $uid | |
} | |
group { $username: | |
gid => $uid, | |
require => user[$username] | |
} | |
file { "/home/$username/": | |
ensure => directory, | |
owner => $username, | |
group => $username, | |
mode => 750, | |
require => [ user[$username], group[$username] ] | |
} | |
file { "/home/$username/.ssh": | |
ensure => directory, | |
owner => $username, | |
group => $username, | |
mode => 700, | |
require => file["/home/$username/"] | |
} | |
# now make sure that the ssh key authorized files is around | |
file { "/home/$username/.ssh/authorized_keys": | |
ensure => present, | |
owner => $username, | |
group => $username, | |
mode => 600, | |
require => file["/home/$username/"] | |
} | |
ssh_authorized_key{ "${username}": | |
ensure => present, | |
key => $key, | |
type => ssh-rsa, | |
user => $username, | |
require => file["/home/$username/.ssh/authorized_keys"] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node default { | |
add_user { joe: | |
email => "[email protected]", | |
name => "Joe Schmoe", | |
uid => 1001, | |
key => "QUFBQUIzTnphQzF5YzJFQUFBQURBUUFCQUFBQkFRQzFlcFRKbXJTU2xUdTk0RnRVMlBoMEVDVDc4Yk5TSWVPcUQwekZ5N3lsdm5kdWticmV5bEcrblRHUzdvTHFWdkhPbkoyM0k5UFJrdWNpQmxiTFdtb3JwUXFKc3Y0bzRWWHZ0U3RGdVIxYmluL0xCQWh1QW1KTzBSWmR5TFhjZGx2Y1RwS01HMGNFZjFxT0ZUN3dpRGtmVFVqeEJDOEVYRFJUTmJ1ZWNxU2REeGQweFc5Tk9HNUlGbmp4TzBjd2g2Q0lrOHpVb29iVTdbckpCbjVoR1hhZXN6VFh4UGtpL2tnYnV1VldIc0xGb05sVm1rL29vOVZQcnBtMGJleTBZOFBxc0RnQmM1U3VoUUNVdnU1L" | |
} | |
add_user { bob: | |
email => "[email protected]", | |
name => "Bob Dole", | |
uid => 1002, | |
key => "QUFBQUIzTnphQzF5YzJFQUFBQURBUUFCQUFBQkFRQzFlcFRKbXJTU2xUdTk0RnRVMlBoMEVDVDc4Yk5TSWVPcUQwekZ5N3lsdm5kdWticmV5bEcrblRHUzdvTHFWdkhPbkoyM0k5UFJrdWNpQmxiTFdtb3JwUXFKc3Y0bzRWWHZ0U3RGdVIxYmluL0xCQWh1QW1KTzBSWmR5TFhjZGx2Y1RwS01HMGNFZjFxT0ZUN3dpRGtmVFVqeEJDOEVYRFJUTmJ1ZWNxU2REeGQweFc5Tk9HNUlGbmp4TzBjd2g2Q0lrOHpVb29iVTdbckpCbjVoR1hhZXN6VFh4UGtpL2tnYnV1VldIc0xGb05sVm1rL29vOVZQcnBtMGJleTBZOFBxc0RnQmM1U3VoUUNVdnU1L" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment