Jira (PUP-10687) file resource with ensure => absent on an existing directory reports out of sync and changed without making any changes

4 views
Skip to first unread message

univerio (Jira)

unread,
Oct 6, 2020, 1:28:05 PM10/6/20
to puppe...@googlegroups.com
univerio created an issue
 
Puppet / Bug PUP-10687
file resource with ensure => absent on an existing directory reports out of sync and changed without making any changes
Issue Type: Bug Bug
Assignee: Unassigned
Components: Types and Providers
Created: 2020/10/06 10:27 AM
Priority: Normal Normal
Reporter: univerio

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.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Josh Cooper (Jira)

unread,
Oct 14, 2020, 2:02:02 PM10/14/20
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-10687
 
Re: file resource with ensure => absent on an existing directory reports out of sync and changed without making any changes

From puppet's perspective, it was told to remove a directory that it can't, so it is an error, and the report reflects that.

univerio (Jira)

unread,
Oct 14, 2020, 2:10:03 PM10/14/20
to puppe...@googlegroups.com
univerio commented on Bug PUP-10687

Josh Cooper Agreed that erroring out would be an acceptable outcome, but it doesn't actually error out:

failed: false
skipped: false

Compare this with the output from an `ensure => file` on an existing directory:

  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.0149569
    tags:
    - file
    - class
    time: '2020-10-14T18:09:20.713609400+00:00'
    failed: true
    failed_to_restart: false
    changed: false
    out_of_sync: true
    skipped: false
    change_count: 0
    out_of_sync_count: 1
    events:
    - audited: false
      property: ensure
      previous_value: directory
      desired_value: file
      historical_value:
      message: 'change from ''directory'' to ''file'' failed: Could not set ''file''
        on ensure: Is a directory - Is a directory: /foo (file: /etc/puppet/manifests/hello.pp,
        line: 1)'
      name: file_created
      status: failure
      time: '2020-10-14T18:09:20.725827600+00:00'
      redacted:
      corrective_change: false
    corrective_change: false
Reply all
Reply to author
Forward
0 new messages