Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-2903

Ensuring directory absent with recursing source fails

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Duplicate
    • Affects Version/s: PUP 3.6.2
    • Fix Version/s: None
    • Component/s: Types and Providers
    • Labels:
      None
    • Environment:

      FreeBSD 10.0-p6, virtualized

      Description

      When managing a File type, I want the ensure parameter to determined from a variable that could be either 'directory' or 'absent'. However, since I define both the 'recurse' and 'source' parameter of this resource, I get an error when ensure is 'absent' and recurse is 'true': puppet complains about trying to put files from the source directory in a directory that isn't there. When I put recurse to 'false', no errors are raised, but then I have to set recurse to false when ensure is absent. This is my workaround for now, but it seems not right.

      Reproduction:

      node default {
       
        file { ['/tmp/foo', '/tmp/foo/bar']:
          ensure => directory,
        }
       
        file { '/tmp/test':
          ensure  => absent,
          recurse => true,
          source  => '/tmp/foo',
        }
      }
      

      This results in:

      Notice: Compiled catalog for localhost in environment production in 1.03 seconds
      Notice: /Stage[main]/Main/Node[default]/File[/tmp/foo]/ensure: created
      Notice: /Stage[main]/Main/Node[default]/File[/tmp/foo/bar]/ensure: created
      Error: Cannot create /tmp/test/bar; parent directory /tmp/test does not exist
      Error: /Stage[main]/Main/Node[default]/File[/tmp/test/bar]/ensure: change from absent to directory failed: Cannot create /tmp/test/bar; parent directory /tmp/test does not exist
      Notice: Finished catalog run in 5.41 seconds

      I would expect that the directory '/tmp/test' would just be deleted. A similar issue was reported and fixed years ago: https://projects.puppetlabs.com/issues/3180
      Could this be regression?

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kylo Kylo Ginsberg
                Reporter:
                skoef Reinier Schoof
                QA Contact:
                Narmadha Perumal
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support