Bug #11159

File resource does not work with '/' to reference root

Added by Stuart Remphrey 5 months ago. Updated 5 months ago.

Status:Accepted Start date:12/05/2011
Priority:Low Due date:
Assignee:- % Done:

0%

Category:file
Target version:2.7.x
Affected Puppet version:2.6.6 Branch:
Keywords:
Votes: 0

Description

The File resource does not work with ‘/’ to reference root, such as to ensure/audit the owner, group and mode, but ‘/.’ does work. Perhaps it is being over-enthusiastic in removing trailing slashes?

This doesn’t work:

file { '/':
    ensure => directory,
    owner  => 0,
    group  => 0,
    mode   => 0755,
    #before => *[*], # everything :-)
}

This does work — and is a reasonable workaround (though mildly annoying and not exactly blindingly obvious at first):

file { '/.':
    ...
}

History

Updated by Josh Cooper 5 months ago

  • Status changed from Unreviewed to Accepted
  • Target version set to 2.7.x

This is actually a problem with the file type’s title pattern:

  def self.title_patterns
    [ [ /^(.*?)\/*\Z/m, [ [ :path, lambda{|x| x} ] ] ] ]
  end

If the file name is ‘/’, then it is not captured by the regex above, so the :path attribute gets set to “”. Later when creating a Puppet::Type::File from the Puppet::Resource, it tries to set path to “”, and the validation routine correctly raises an error.

I could have sworn this is a duplicate of an issue I looked at last week, but I can’t find it.

Updated by Josh Cooper 5 months ago

  • Status changed from Accepted to Duplicate

This is fixed in 2.7.7rc1

Updated by Josh Cooper 5 months ago

  • Status changed from Duplicate to Re-opened

edited the wrong entry

Updated by Josh Cooper 5 months ago

  • Status changed from Re-opened to Accepted

Also available in: Atom PDF