If I use the ''file'' type to sync a file where the parent directory doesn''t exist the sync fails. According to the puppet docs "Puppet will autorequire any parent directories that are being managed". Am i missing something? Example: file { "/tmp/dhcp/dhcpd.include": source => "/tmp/dhcpd.include", } In this example the /tmp/dhcp/ directory does not exist so i would expect puppet to create it. Error returned (puppetd --debug): Could not set file on ensure: No such file or directory - /tmp/dhcp/dhcpd.include.puppettmp at /etc/puppet/manifests/classes/bootserver.pp:35 err: /boot.xx.clivepeeters.com.au/bootserver/File[/tmp/dhcp/dhcpd.include]/ensure: change from absent to file failed: Could not set file on ensure: No such file or directory - /tmp/dhcp/dhcpd.include.puppettmp at /etc/puppet/manifests/classes/bootserver.pp:35 If I attempt to create a require for the directory I also get a fail. Example: file { "/tmp/dhcp/": ensure => directory } file { "/tmp/dhcp/dhcpd.include": source => "/tmp/dhcpd.include", require => File["/tmp/dhcp/"] } Error returned (puppetd --debug): err: Could not apply complete configuration: Could not retrieve dependency ''File[/tmp/dhcp/]'' at /etc/puppet/manifests/classes/bootserver.pp:39 This works: file { "/tmp/dhcp/": ensure => directory, alias => "tmp-dhcp" } file { "/tmp/dhcp/dhcpd.include": source => "/tmp/dhcpd.include", require => File["tmp-dhcp"] } Any help would be appreciated. Your truly, Ben
On Jan 15, 2007, at 6:05 PM, Abnormaliti wrote:> If I use the ''file'' type to sync a file where the parent directory > doesn''t exist the sync fails. According to the puppet docs "Puppet > will > autorequire any parent directories that are being managed". Am i > missing something? > > Example: > > file { "/tmp/dhcp/dhcpd.include": > source => "/tmp/dhcpd.include", > } > > In this example the /tmp/dhcp/ directory does not exist so i would > expect puppet to create it.If you are managing both the parent directory and the contained file, then Puppet will automatically create a relationship between those resources. Puppet will not automatically create a resource to manage the parent directory, though -- you have to explicitly create a resource to do so. -- Always behave like a duck - keep calm and unruffled on the surface but paddle like the devil underneath. -- Jacob Braude --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
Luke Kanies wrote:> If you are managing both the parent directory and the contained file, > then Puppet will automatically create a relationship between those > resources. Puppet will not automatically create a resource to manage > the parent directory, though -- you have to explicitly create a > resource to do so. > > -- > Always behave like a duck - keep calm and unruffled on the surface but > paddle like the devil underneath. -- Jacob Braude > --------------------------------------------------------------------- > Luke Kanies | http://reductivelabs.com | http://madstop.com > >Luke, Can you explain why this doesn''t work? Have I got the syntax correct? Example: file { "/tmp/dhcp/": ensure => directory } file { "/tmp/dhcp/dhcpd.include": source => "/tmp/dhcpd.include", require => File["/tmp/dhcp/"] } Error returned (puppetd --debug): err: Could not apply complete configuration: Could not retrieve dependency ''File[/tmp/dhcp/]'' at /etc/puppet/manifests/classes/bootserver.pp:39 Ben
On Jan 16, 2007, at 11:02 AM, Abnormaliti wrote:> Luke, > > Can you explain why this doesn''t work? Have I got the syntax correct? > > Example: > > file { "/tmp/dhcp/": > ensure => directory > } > > file { "/tmp/dhcp/dhcpd.include": > source => "/tmp/dhcpd.include", > require => File["/tmp/dhcp/"] > } > > Error returned (puppetd --debug): > > err: Could not apply complete configuration: Could not retrieve > dependency ''File[/tmp/dhcp/]'' at > /etc/puppet/manifests/classes/bootserver.pp:39Hmm. This is a weird problem. Puppet helpfully clears out the trailing slash when you create the /tmp/dhcp resource, but does not clear it out when trying to retrieve it, which is a bug. For now, use ''require => File["/tmp/dhcp"]'' (note the lack of a trailing slash), but this is a pretty easy bug to fix. -- Today I dialed a wrong number...The other person said, "Hello?" and I said, "Hello, could I speak to Joey?"... They said, "Uh...I don''t think so...he''s only 2 months old." I said, "I''ll wait." -- Steven Wright --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
Luke Kanies wrote:> On Jan 16, 2007, at 11:02 AM, Abnormaliti wrote: > >> Luke, >> >> Can you explain why this doesn''t work? Have I got the syntax correct? >> >> Example: >> >> file { "/tmp/dhcp/": >> ensure => directory >> } >> >> file { "/tmp/dhcp/dhcpd.include": >> source => "/tmp/dhcpd.include", >> require => File["/tmp/dhcp/"] >> } >> >> Error returned (puppetd --debug): >> >> err: Could not apply complete configuration: Could not retrieve >> dependency ''File[/tmp/dhcp/]'' at >> /etc/puppet/manifests/classes/bootserver.pp:39 >> > > Hmm. This is a weird problem. Puppet helpfully clears out the > trailing slash when you create the /tmp/dhcp resource, but does not > clear it out when trying to retrieve it, which is a bug. > > For now, use ''require => File["/tmp/dhcp"]'' (note the lack of a > trailing slash), but this is a pretty easy bug to fix. > > -- > Today I dialed a wrong number...The other person said, "Hello?" and > I said, "Hello, could I speak to Joey?"... > They said, "Uh...I don''t think so...he''s only 2 months old." > I said, "I''ll wait." -- Steven Wright > --------------------------------------------------------------------- > Luke Kanies | http://reductivelabs.com | http://madstop.com > > > _______________________________________________ > Puppet-users mailing list > Puppet-users@madstop.com > https://mail.madstop.com/mailman/listinfo/puppet-users > > >Thanks Luke, I will remember that for the future. I have created a function for remotefile retrieval that has the option to create parent directories if anyone is interested. ++++++++++++++++++++++++++++++++++ define remotefile($path, $owner = root, $group = root, $mode = 755, $mkdir = false ){ case $mkdir { true: { exec { "mkdir-$name": command => "/usr/bin/install -d -o $owner -g $group \$(dirname $path)", onlyif => "test ! -d \$(dirname $path)", path => "/usr/bin/:/bin/" } } } file { $name: path => $path, source => [ "puppet://$server/files/$type/$version/$path.$subdomain", "puppet://$server/files/$type/$version/$path.$state", "puppet://$server/files/$type/$version/$path", "puppet://$server/files/common/$path.$subdomain", "puppet://$server/files/common/$path.$state", "puppet://$server/files/common/$path" ], owner => $owner, group => $group, mode => $mode, recurse => true } } ++++++++++++++++++++++++++++++++++
On Tue, Jan 16, 2007 at 12:20:41PM +1100, Abnormaliti wrote:> Thanks Luke, I will remember that for the future. I have created a > function for remotefile retrieval that has the option to create parent > directories if anyone is interested.That looks like it would look really good in the cookbook (http://reductivelabs.com/cookbook/). - Matt -- "I''m tempted to try Gentoo, but then I learned that its installer is in Python, and, well, a base Python install on my system is something like fifty megabytes (for what? oh, right, we NEED four XML libraries, I forgot)." -- Dave Brown, ASR