Ask Your Question
1

Cannot create parent directory - managehome? hyphen?

asked 2014-02-06 12:20:21 -0500

ericfrancis gravatar image

updated 2014-02-06 14:08:36 -0500

Does managehome create a users home directory? Are usernames allowed to contain hyphens (example-app instead of example)?

My default.pp:

$user = example

user { $user :
  ensure     => present,
  managehome => yes,
  shell      => "/bin/bash"
}

file { "/home/${user}/.ssh":
  ensure  => 'directory',
  require => User[$user],
  owner   => $user,
  mode    => '700',
}

error message:

Warning: Could not retrieve fact fqdn 
Error: Cannot create /home/example/.ssh; parent directory /home/example does not exist 
Error: /Stage[main]/Main/File[/home/example/.ssh]/ensure: change from absent to directory failed: Cannot create /home/example/.ssh; parent directory /home/example does not exist
edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
3

answered 2014-02-06 14:27:31 -0500

Stefan gravatar image

updated 2014-02-06 15:16:07 -0500

The file resource does not create parent directories. You either have to manage all parent directories with explicit file resources (recommended way) or you use an exec resource that runs mkdir -p (not recommended).

There was alot of debate around that topic but it was finally decided that the file resource should not create parent directories. The rejected feature request with different reasons can be found here

The reason why your home directory is not created when applying your user resource is because you pass yes to managehome while it should be true. Puppet should normally warn you about an ... (more)

edit flag offensive delete link more
0

answered 2014-02-06 14:15:17 -0500

ericfrancis gravatar image

updated 2014-02-06 14:15:27 -0500

Yes, managehome does create the user's home directory.

No, the user name cannot contain a hyphen.

edit flag offensive delete link more
0

answered 2014-02-17 13:59:09 -0500

cristaldo gravatar image

updated 2014-02-17 15:14:45 -0500

Stefan gravatar image

Here is the Right Manifest!

$user = example

user { $user:
  ensure     => present,
  managehome => yes,
  home       => "/home/${user}",
  shell      => "/bin/bash",
}

file { "/home/${user}/.ssh":
  ensure  => 'directory',
  owner   => $user,
  mode    => '0700',
  require => User[$user],
}
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

2 followers

Stats

Asked: 2014-02-06 12:20:21 -0500

Seen: 1,398 times

Last updated: Feb 17 '14