From 78fdb4e794e0858c058694a5db8790fb08fe853f Mon Sep 17 00:00:00 2001 From: Bryan Jen Date: Thu, 28 May 2015 16:51:35 -0700 Subject: [PATCH] adds file autorequire autorequire will add parent directories of the concat_file to the dependency chain. So they can be created in the right order if they do not exist. --- lib/puppet/type/concat_file.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/puppet/type/concat_file.rb b/lib/puppet/type/concat_file.rb index 9b3fde4dc..79776c5bd 100644 --- a/lib/puppet/type/concat_file.rb +++ b/lib/puppet/type/concat_file.rb @@ -89,6 +89,22 @@ def exists? end.compact end + # Copied from puppet's file type + # Autorequire the nearest ancestor directory found in the catalog. + autorequire(:file) do + req = [] + path = Pathname.new(self[:path]) + if !path.root? + # Start at our parent, to avoid autorequiring ourself + parents = path.parent.enum_for(:ascend) + if found = parents.find { |p| catalog.resource(:file, p.to_s) } + req << found.to_s + end + end + + req + end + def should_content return @generated_content if @generated_content @generated_content = ""