The Puppet Labs Issue Tracker has Moved: https://tickets.puppetlabs.com

Feature #5421

Fileresource: Link should autorequire target

Added by Stefan Schulte about 4 years ago. Updated almost 3 years ago.

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

0%

Category:file
Target version:2.7.10
Affected Puppet version: Branch:https://github.com/stschulte/puppet/tree/feature/2.7.x/5421
Keywords:

We've Moved!

Ticket tracking is now hosted in JIRA: https://tickets.puppetlabs.com

This issue is currently not available for export. If you are experiencing the issue described below, please file a new ticket in JIRA. Once a new ticket has been created, please add a link to it that points back to this Redmine ticket.


Description

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?

History

#1 Updated by James Turnbull about 4 years ago

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

#2 Updated by Stefan Schulte about 4 years ago

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

  • https://github.com/stschulte/puppet/tree/feature/next/5421

  • https://github.com/stschulte/puppet/commit/09bec5b4272d429f3c1a527f64610f5161536f38

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 over 3 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?

http://docs.puppetlabs.com/references/stable/type.html#file

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

#4 Updated by Stefan Schulte over 3 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',
}

or

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 over 3 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 over 3 years ago

  • Branch set to https://github.com/stschulte/puppet/tree/feature/2.7.x/5421

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 over 3 years ago

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

awesome. Thanks Stefan!

#8 Updated by Stefan Schulte over 3 years ago

pull request: https://github.com/puppetlabs/puppet/pull/96

#9 Updated by Patrick Carlisle about 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 about 3 years ago

  • Target version changed from 2.7.8 to 2.7.9

#11 Updated by Michael Stahnke almost 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