Puppet: System Administration Automated

Support

Adding a User and their Home directory

This might help someone. If you're using a version higher than 0.22.1, this is probably fixed already, so you can simply check the reference to see how you should add a homedir directly from the user {} declaration. Otherwise, you can use this component:

define user_homedir ($group, $fullname, $ingroups) {
  user { "$name":
    ensure => present,
    comment => "$fullname",
    gid => "$group",
    groups => $ingroups,
    membership => minimum,
    shell => "/bin/bash",
    home => "/home/$name",
    require => Group[$group],
  }

  exec { "$name homedir":
    command => "/bin/cp -R /etc/skel /home/$name; /bin/chown -R $name:$group /home/$name",
    creates => "/home/$name",
    require => User[$name],
  }
}

You can use it like this:

user_homedir { "donkeyman":
  group => "donkeys",
  fullname => "Equus Asinus",
  ingroups => ["animalia", "chrodata", "mammalia", "perissodactyla", "equidae", "equus"],
}