0

I'm trying to uninstall packageA with puppet, however puppet doesn't uninstall.

My package resource looks like this:

  package {
    'packageA':
      ensure            => absent,
      provider          => rpm,
      alias             => 'packageA',
      name              => 'packageA',
      uninstall_options => ['--nodeps'],
  }

Here are the --debug puppet logs for that package:

Debug: /Package[packageA]: Provider rpm does not support features targetable; not managing attribute command


Debug: Executing: '/bin/rpm --version'
Debug: Executing '/bin/rpm -qa --nosignature --nodigest --qf '%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n' | sort'
Debug: Executing: '/bin/rpm -q packageA --nosignature --nodigest --qf %{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n'
Debug: Executing: '/bin/rpm -q packageA --nosignature --nodigest --qf %{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n --whatprovides'
Debug: /Package[packageA]: Nothing to manage: no ensure and the resource doesn't exist

I don't see puppet executing rpm -e --nodeps packageA anywhere. Am I missing something?

Please note that if I have rpm -e packageA --nodeps in an exec resource, it uninstalls the package. But I'd like to know what's wrong with the package resource above.

Thanks in advance.

Yong zhu
  • 103
  • 1
  • 1
  • 6

2 Answers2

1

Try this

package { 'packageA':
  ensure            => absent,
  alias             => 'packageA-<version or arch>',
  uninstall_options => ['--nodeps'],
}

It's good practice not to specify the provider, one of the advantages of Puppet is the abstraction layers, it'll figure out the correct provider for you so your code will run on any OS, you may find Puppet successfully removes this package with yum. Just leave that complexity to Puppet to sort out.

You only need the alias if the package might be known as a different name, a yum info should tell you this or an rpm -qa packageA, that would have been useful to add to the original question.

You generally won't need to specify the name as it defaults to the resource title.

https://puppet.com/docs/puppet/5.5/types/package.html

16c7x
  • 500
  • 2
  • 6
0

I don't see puppet executing rpm -e --nodeps packageA anywhere. Am I missing something?

Yes and no and maybe.

Do you see ...

Debug: /Package[packageA]: Nothing to manage: no ensure and the resource doesn't exist

? That's telling you that Package packageA isn't installed in the first place. In that case, Puppet does not need to do anything to make it absent. In particular, it will not execute a rpm -e command for a package that isn't (initially) installed in the first place.

However, that message also says "no ensure". Perhaps that exhibits a bug, but it seems to be telling you that the Package it is applying does not have an ensure attribute expressed, which would mean that the output presented does not go with the code presented. Still, that doesn't change anything in the previous paragraph.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157