Ask Your Question

user home directory not created when user already exist

asked 2014-01-21 04:09:28 -0600

jaksky gravatar image

updated 2014-01-21 04:26:23 -0600


I have following user definition:

    user { "${hadoop::hdfs_user}":
     ensure     => present,
     managehome => true,
     home       => "/home/${hadoop::hdfs_user}",
     gid        => "${hadoop::hadoop_group}",
     shell      => '/bin/bash',
     password   => 'xxx',     
     comment    =>'hdfs user',
     require    => Group["${hadoop::hadoop_group}"],

But the home directory is not created after puppet run. This user already exist bacause some rpm installation already created that. When I check my manifest with puppet resource command:

user { 'hdfs':
  ensure           => 'present',
  comment          => 'hdfs user',
  gid              => '502',
  groups           => ['hadoop'],
  home             => '/home/hdfs',
  password         => 'xxx',
  password_max_age => '-1',
  password_min_age => '-1',
  shell            => '/bin/bash',
  uid              => '485',

However home directory is not created. Any hints? Using CentOS 6

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2014-01-21 12:31:07 -0600

Stefan gravatar image

The managehome attribute is only a parameter that is taken into account when puppet has to perform a create/destroy action. This is not something that puppet will actually check during each puppet run.

In other words if your user is absent and puppet creates the user it will use useradd with the -m argument (which will probably also copy the skeleton directory to the new user's homedir) and will use userdel with the -r flag to remove the user's home directory and spool files if puppet has to remove the user.

If you want to ensure that ... (more)

edit flag offensive delete link more


I used that approach as a workaround and didn't know that it is correct solution :-)

jaksky gravatar imagejaksky ( 2014-01-21 13:18:29 -0600 )edit

answered 2014-01-21 07:35:05 -0600

ethrbunny gravatar image

You could use a file{ ... : ensure=>"folder".. } (with appropriate owner) entry. Esp if you knew in advance that the account already existed.

edit flag offensive delete link more

answered 2014-01-21 10:20:01 -0600

lavaman gravatar image

You need managehome => true

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-01-21 04:09:28 -0600

Seen: 4,357 times

Last updated: Jan 21 '14