The Puppet Labs Issue Tracker has Moved:

This issue tracker is now in read-only archive mode and automatic ticket export has been disabled. Redmine users will need to create a new JIRA account to file tickets using See the following page for information on filing tickets with JIRA:

Feature #5421

Fileresource: Link should autorequire target

Added by Stefan Schulte almost 5 years ago. Updated over 3 years ago.

Status:ClosedStart date:11/30/2010
Priority:NormalDue date:
Assignee:Stefan Schulte% Done:


Target version:2.7.10
Affected Puppet version: Branch:

We've Moved!

Ticket tracking is now hosted in JIRA:


When you manage links with puppet it’s possible that you have to define explicit requires. Example:

file { '/foo/bar':
  ensure => directory,
file { '/link':
  ensure => link,
  target => '/foo/bar',

This works, because you can create a dead link. But if you now do

file { '/link/i_dont_care_it_was_a_link':
  ensure => file,

this fileresource does autorequire the link, but you cannot be sure, that the target exists. I would like that File['/link'] autorequires File['/foo/bar'].

Anything that speaks against this autorequire?


#1 Updated by James Turnbull almost 5 years ago

  • Status changed from Unreviewed to Needs Decision
  • Assignee set to Nigel Kersten

#2 Updated by Stefan Schulte almost 5 years ago

I implemented the autorequire. You can see it in my branch



I don’t know if this patch has any impact if you are managing links recursive, because I never used that feature.

#3 Updated by Nigel Kersten about 4 years ago

  • Status changed from Needs Decision to Needs More Information
  • Assignee changed from Nigel Kersten to Stefan Schulte
  • Target version set to 3.x

Stefan, I think we should make the autorequire conditional upon the setting of the “links” parameter?

If it’s set to “follow” or “ignore” we shouldn’t autorequire I don’t think ?

#4 Updated by Stefan Schulte almost 4 years ago

The links parameter only specifies what puppet should do when copying files to the machine (copy a link or copy the target) or managing contents, right?. I was talking about using a file resource to make sure a local link exists. Like in

file { '/lib':
  ensure => '/lib64',


file { '/lib':
  ensure => link,
  target => '/lib64',

And the link File['/lib'] should autorequire the target (so File['/lib64'] in this case). This would prevent puppet from creating dead links and managing File['/lib/foo'] before the link File['/lib'] actually points to a directory.

So I in my opinion the autorequire should be unconditionally (or I didnt got your point).

#5 Updated by Nigel Kersten almost 4 years ago

Ah now I understand. So your patch definitely only affects File resources that are symlinks? and works happily whether you specify the target with ensure or target ?

#6 Updated by Stefan Schulte almost 4 years ago

  • Branch set to

The patch just drops target in the autorequire array. And I am not aware of any other meaning for target than saying that the described file should be a symlink.

I rebased the branch and added a test to ensure that both ways (target via target property or target via ensure property) do work.

#7 Updated by Nigel Kersten almost 4 years ago

  • Status changed from Needs More Information to In Topic Branch Pending Review

awesome. Thanks Stefan!

#8 Updated by Stefan Schulte almost 4 years ago

pull request:

#9 Updated by Patrick Carlisle over 3 years ago

  • Status changed from In Topic Branch Pending Review to Merged - Pending Release
  • Target version changed from 3.x to 2.7.8

Merged commit:4ca51f8a4ff0969251d5f224e52d3d126e12fa95

(#5421) Link should autorequire target

When we manage a local link to a directory and the target directory is
managed by puppet as well, establish an autorequire. So if we have
something like

  file { '/foo': ensure => directory }
  file { '/link_to_foo': ensure => '/foo' }
  file { '/link_to_foo/bar': ensure => file }

we can ensure that puppet does not create dead links and does not try to
create '/link_to_foo/bar' before /foo is created.

#10 Updated by Patrick Carlisle over 3 years ago

  • Target version changed from 2.7.8 to 2.7.9

#11 Updated by Michael Stahnke over 3 years ago

  • Status changed from Merged - Pending Release to Closed
  • Target version changed from 2.7.9 to 2.7.10

released in 2.7.10rc1

Also available in: Atom PDF