Ask Your Question

Could not find dependency User root for File

asked 2015-02-28 00:05:00 -0500

stephen gravatar image


I believe I'm trying to so something very simple, but it's not working. I have a set of directories that I want to ensure are present with the proper ownership, so I define them all upfront and then realize them where I need to make sure they are present. When I use require User['root'] or Group['root'] in the virtual definition, I get a "Could not find dependency" error.


@file { "/home":
    owner               =>  'root',
    group                =>  'root',
    mode                =>  0755,
    require              =>  [ User['root'], Group['root'] ],

This may very well be a newbie type issue, but I've read and read and tried and tried and I must be missing something really simple, because this cannot be a very complicated objective.

Also, if I do a "puppet resource user root", of course the root user is found.

user { 'root':
  ensure           => 'present',
  comment          => 'root',
  gid              => '0',
  home             => '/root',
  password         => '<removed for security>',
  password_max_age => '99999',
  password_min_age => '0',
  shell            => '/bin/bash',
  uid              => '0',

thanks, Stephen

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-02-28 14:04:53 -0500

doc75 gravatar image

Actually you need to have the user root definition somewhere in your puppet manifests otherwise it is not complete. When you reference a resource, it has to exist somewhere in your manifest (no matter if it exists already on the machine or not).

In your case, just remove the require case, as it is useless (root should always exist).

puppet resource just retrieve information on current system to give you the way to declare a ressource.

Hope I am clear (not sure ;-) )

edit flag offensive delete link more


Thanks. Makes sense, though does not entirely solve my problem. Trying to abstract the creation of parent dirs, some owned by non-root users, hence the require in all cases. Seems I need to do a user{'root':} even though I know root already exists? Could I verify a fact rather than use require?

stephen gravatar imagestephen ( 2015-02-28 14:46:30 -0500 )edit

To doc75's point, whenever you use resource reference syntax ( the referenced resource must be declared somewhere in your Puppet code, even if it's as simple as "user { 'root': ensure => present, }".

GregLarkin gravatar imageGregLarkin ( 2015-03-02 12:08:15 -0500 )edit

Thanks as well. I finally figured that out, but then ran into an issue because I had to declare "user {'root': ensure => present}" multiple times (not allowed!) before each Realization, as I could not guarantee which would come first. For now, I've solved the problem, by assuming that root exists.