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

file resource with ensure => absent on an existing directory reports out of sync and changed without making any changes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Incomplete
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Types and Providers
    • Labels:
      None
    • Template:
      PUP Bug Template
    • Method Found:
      Needs Assessment
    • QA Risk Assessment:
      Needs Assessment

      Description

      Puppet Version: 6.18.0
      Puppet Server Version: n/a (standalone)
      OS Name/Version: Ubuntu 18.04

      With the manifest

      file { "/foo":
        ensure => absent;
      }
      

      and a directory already exists at /foo, puppet currently refuses to remove /foo because force is not true. I'm applying this manifest using

      puppet apply manifest.pp
      

      This issue concerns the generated report.

      Desired Behavior:

      The resulting report should be as if the manifest were

      file { "/foo":
        ensure => directory;
      }
      

      because without force => true the desired end state on the host is to keep the directory around. Example report output:

      resource_statuses:
        File[/foo]:
          title: "/foo"
          file: "/etc/puppet/manifests/hello.pp"
          line: 1
          resource: File[/foo]
          resource_type: File
          provider_used: posix
          containment_path:
          - Stage[main]
          - Main
          - File[/foo]
          evaluation_time: 0.000349
          tags:
          - file
          - class
          time: '2020-10-06T17:19:02.736067500+00:00'
          failed: false
          failed_to_restart: false
          changed: false
          out_of_sync: false
          skipped: false
          change_count: 0
          out_of_sync_count: 0
          events: []
          corrective_change: false
      

      Actual Behavior:

      The report claims that the resource File[/foo] was out of sync and changed when no action has been taken:

      resource_statuses:
        File[/foo]:
          title: "/foo"
          file: "/etc/puppet/manifests/hello.pp"
          line: 1
          resource: File[/foo]
          resource_type: File
          provider_used: posix
          containment_path:
          - Stage[main]
          - Main
          - File[/foo]
          evaluation_time: 0.0007467
          tags:
          - file
          - class
          time: '2020-10-06T17:19:55.896593800+00:00'
          failed: false
          failed_to_restart: false
          changed: true
          out_of_sync: true
          skipped: false
          change_count: 1
          out_of_sync_count: 1
          events:
          - audited: false
            property: ensure
            previous_value: directory
            desired_value: absent
            historical_value:
            message: removed
            name: file_removed
            status: success
            time: '2020-10-06T17:19:55.896801400+00:00'
            redacted:
            corrective_change: false
          corrective_change: false
      

      This means that puppet will perpetually report the status as changed.

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            univerio univerio
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Zendesk Support