Ask Your Question

require dir fails BUT dir does exist

asked 2016-08-29 20:51:23 -0500

cm01 gravatar image

updated 2016-08-30 18:10:47 -0500

Error: Failed to apply catalog: Could not find dependency File[/var/www/html] for Vixiecron[postgres91_nslb] at /etc/puppetlabs/code/environments/prod/modules/pgsql/manifests/classes/monitoring.pp:3

 ll /var/www/html
    total 12
    -rw-r--r-- 1 root root    3 Jun  9 17:00 a11.txt
    -rw-r--r-- 1 root root   44 Nov 14  2014 index.php
    drwxr-xr-x 2 root root 4096 Nov 11  2014 maintenance
    -rw-r--r-- 1 root root    0 Nov 25  2014 statistics

As you can see, the dir in qn does exist, so why the error ?


Thanks for the info guys.
Actually i'm trying to look for possible erors when converting Puppet v3 to Puppet v4. In this case I'm running with --noop, so occasionally having to comment out stuff that can't be fixed right now, to see what happens next... As it happens, the file is a defined resource ...

edit retag flag offensive close merge delete



Is the directory managed by Puppet and declared somewhere on your manifest? i.e file { '/var/www/html': file => 'directory' } should exist on your manifest.

lupin gravatar imagelupin ( 2016-08-30 03:18:32 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-08-30 07:56:22 -0500

DarylW gravatar image

the capital letter resource name refers to a resource declared by a different part of you puppet manifest. if you do require => File['/tmp/foo'], there exists a directory named /tmp/foo on your system, but it ISN'T in your manifest, puppet won't create it's own resource to handle the directory, it will fail.

If the directory exists but there is no file resource within your manifest, you can't require that (non-existent) resource. You have two options.

1) If you KNOW that something creates that directory for you (installing apache or nginx for example) then you can depend on that portion of your code. 2) Embrace the declarative nature of puppet and add that file resource to your manifests, then you can require it as normal. That will ensure the file/directory exists as you would expect it to with the settings you expect. IF you are relying on something else to set it up and configure it, and it's configuration changes, you'll need to be aware of that and update your configuration to match.

Main takeaway is that puppet won't arbitrarily create a resource for you if you refer to a non-existent (within the puppet manifest) resource, it will just fail to find it.

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


Asked: 2016-08-29 20:51:23 -0500

Seen: 61 times

Last updated: Aug 30 '16