Christopher Wood
2012-May-15 17:05 UTC
[Puppet Users] odd behaviour on file ensure => absent
Here''s my test (done on Debian Stable with puppet 2.7.13 from the puppetlabs apt repository): $ cat /tmp/t1.pp file { ''/tmp/xx/yy/zz/1'': ensure => absent, } $ ls /tmp/xx ls: cannot access /tmp/xx: No such file or directory $ puppet apply /tmp/t1.pp notice: Finished catalog run in 0.02 seconds $ touch /tmp/xx $ puppet apply /tmp/t1.pp err: /Stage[main]//File[/tmp/xx/yy/zz/1]: Could not evaluate: Not a directory - /tmp/xx/yy/zz/1 notice: Finished catalog run in 0.02 seconds It seems counter-intuitive that if /tmp/xx is a regular file then this causes the manifest run to fail. If /tmp/xx is a regular file then /tmp/xx/yy/zz/1 can''t exist. Does anybody use this behaviour for anything? I found this while testing if it would work with only one subdirectory of a deep path, without realizing that /tmp/xx was a regular file not a directory. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Stefan Schulte
2012-May-19 18:40 UTC
Re: [Puppet Users] odd behaviour on file ensure => absent
On Tue, May 15, 2012 at 01:05:03PM -0400, Christopher Wood wrote:> Here''s my test (done on Debian Stable with puppet 2.7.13 from the puppetlabs apt repository): > > > $ cat /tmp/t1.pp > file { ''/tmp/xx/yy/zz/1'': > ensure => absent, > } > $ ls /tmp/xx > ls: cannot access /tmp/xx: No such file or directory > $ puppet apply /tmp/t1.pp > notice: Finished catalog run in 0.02 seconds > $ touch /tmp/xx > $ puppet apply /tmp/t1.pp > err: /Stage[main]//File[/tmp/xx/yy/zz/1]: Could not evaluate: Not a directory - /tmp/xx/yy/zz/1 > notice: Finished catalog run in 0.02 seconds > > > It seems counter-intuitive that if /tmp/xx is a regular file then this causes the manifest run to fail. If /tmp/xx is a regular file then /tmp/xx/yy/zz/1 can''t exist. Does anybody use this behaviour for anything? > > I found this while testing if it would work with only one subdirectory of a deep path, without realizing that /tmp/xx was a regular file not a directory. >Hi Christopher, can you raise a ticket for that on redmine as it is clearly a bug? (http://projects.puppetlabs.com/issues) The reason is that puppet does a stat call on the path /tmp/xx/yy/zz/1 to get ownership, mode etc and this will of course fail if the file is not present. Now the stat system call can raise different errors (http://linux.die.net/man/2/stat): EACCES - Search permission is denied for one of the directories in the path prefix of path (this one is handled by puppet) ENOENT - A component of path does not exist, or path is an empty string. (this one is also handled by puppet and the reason why your first run does not raise an error) ENOTDIR - A component of the path prefix of path is not a directory. The last error is *not* handled in the puppet code and is considered a bug. So raising a ticket "file resource should handle ENOTDIR" would be great. If you don''t want to open it yourself just say so and I''ll be happy to do it instead. -Stefan -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Christopher Wood
2012-May-20 16:42 UTC
Re: [Puppet Users] odd behaviour on file ensure => absent
On Sat, May 19, 2012 at 08:40:27PM +0200, Stefan Schulte wrote: (SNIP)> can you raise a ticket for that on redmine as it is clearly a bug?https://projects.puppetlabs.com/issues/14599 -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.