Package resource action :purge does nothing when package is not installed


#1

The subject says it all :slight_smile:

I’ve got a recipe that purge a package, but I noticed that if the package is not installed, :purge doesn’t do anything, potentially leaving configuration files behind.

In my specific use case, I have uninstalled the package manually, so I have it in the “c” state on the apt system – this is on Ubuntu 12.04. I would have expected :purge to actually purge the package.

Is the current behaviour expected, is it a bug, or am I missing something?

Thanks!

  • cassiano

#2

Sounds like a bug due to idempotency checking in the package provider!

I’d expect purge (although naturally, it is a dpkg provider action
technically) to purge all states that are able to be purged, including
dpkg ‘c’ state.

It looks like the way the apt and dpkg providers are written
(subclassed from Package base) they explicitly check if the package is
’being removed’ before allowing a purge. You may be able to adjust
this method temporarily (with a monkey patch, or similar) in order to
affect some test resolution. [0]

Open a ticket up :slight_smile:

–AJ

[0] https://github.com/opscode/chef/blob/master/lib/chef/provider/package.rb#L113-L133

On 6 March 2013 08:33, Cassiano Leal cassianoleal@gmail.com wrote:

The subject says it all :slight_smile:

I’ve got a recipe that purge a package, but I noticed that if the package is
not installed, :purge doesn’t do anything, potentially leaving configuration
files behind.

In my specific use case, I have uninstalled the package manually, so I have
it in the “c” state on the apt system – this is on Ubuntu 12.04. I would
have expected :purge to actually purge the package.

Is the current behaviour expected, is it a bug, or am I missing something?

Thanks!

  • cassiano

#3

Looks like I should have searched for one before asking! :slight_smile:

http://tickets.opscode.com/browse/CHEF-3419

  • cassiano

On Tuesday, March 5, 2013 at 16:40, AJ Christensen wrote:

Sounds like a bug due to idempotency checking in the package provider!

I’d expect purge (although naturally, it is a dpkg provider action
technically) to purge all states that are able to be purged, including
dpkg ‘c’ state.

It looks like the way the apt and dpkg providers are written
(subclassed from Package base) they explicitly check if the package is
’being removed’ before allowing a purge. You may be able to adjust
this method temporarily (with a monkey patch, or similar) in order to
affect some test resolution. [0]

Open a ticket up :slight_smile:

–AJ

[0] https://github.com/opscode/chef/blob/master/lib/chef/provider/package.rb#L113-L133

On 6 March 2013 08:33, Cassiano Leal <cassianoleal@gmail.com (mailto:cassianoleal@gmail.com)> wrote:

The subject says it all :slight_smile:

I’ve got a recipe that purge a package, but I noticed that if the package is
not installed, :purge doesn’t do anything, potentially leaving configuration
files behind.

In my specific use case, I have uninstalled the package manually, so I have
it in the “c” state on the apt system – this is on Ubuntu 12.04. I would
have expected :purge to actually purge the package.

Is the current behaviour expected, is it a bug, or am I missing something?

Thanks!

  • cassiano