puppet-python icon indicating copy to clipboard operation
puppet-python copied to clipboard

Installing Python36 not idempotent

Open 00kfulton00 opened this issue 6 years ago • 3 comments
trafficstars

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 4.10.12
  • Ruby:
  • Distribution: CentOS Linux 7
  • Module version: 3.0.1

How to reproduce (e.g Puppet code you use)

class { 'python': version => '36', pip => 'latest', }

python::pip { 'packaging' : ensure => '19.0', pkgname => 'packaging', }

What are you seeing

Error: Execution of '/usr/bin/yum -d 0 -e 0 -y install python36' returned 1: Error: Nothing to do Error: /Stage[main]/Python::Install/Package[python]/ensure: change from purged to present failed: Execution of '/usr/bin/yum -d 0 -e 0 -y install python36' returned 1: Error: Nothing to do

What behaviour did you expect instead

The module to run without errors.

Output log

Any additional information you'd like to impart

The module is failing during a spec test that tests is the module is idempotent. The manifest is applied twice, and the installation of python, pip and the package is successful. The test fails due to the error messages noted above, is there any way to avoid the false negative response of "Nothing to do" it seems like an error reproduced by yum after detecting an existing installation of python.

00kfulton00 avatar Jul 16 '19 17:07 00kfulton00

Hi @00kfulton00 . What test are you talking about? Can you provide a link ?

Dan33l avatar Jul 17 '19 09:07 Dan33l

I've written a few spec test for my environment; I've written a test(server spec/beaker) in that it applies the manifest twice to check for changes, see code excerpt below below:

require 'beaker-rspec/helpers/serverspec'
require 'beaker/puppet_install_helper'
require 'beaker/module_install_helper'```

run_puppet_install_helper unless ENV['BEAKER_provision'] == 'no'
install_module_on(hosts)
install_module_dependencies_on(hosts)

RSpec.configure do |c|
   _Readable test descriptions_
  c.formatter = :documentation

   _Configure all nodes in nodeset_
  c.before :suite do
    # Install module and dependencies
    hosts.each do |host|
      on host, '/opt/puppetlabs/puppet/bin/gem install lookup_http'
      if fact_on(host, 'osfamily') == 'RedHat'
        # don't delete downloaded rpm for use with BEAKER_provision=no +
        # BEAKER_destroy=no
        on host, 'sed -i "s/keepcache=.*/keepcache=1/" /etc/yum.conf'
        # refresh check if cache needs refresh on next yum command
        on host, 'yum clean expire-cache'
      end
    end
  end
end

shared_examples 'a idempotent resource' do
  it 'applies with no errors' do
    apply_manifest(pp, catch_failures: true)
  end

  it 'applies a second time without changes' do
    apply_manifest(pp, catch_changes: true)
  end
end
`

00kfulton00 avatar Jul 17 '19 15:07 00kfulton00

If you upgrade to puppet 6x, your proposed code works:

class { 'python': version => '36', pip => 'latest', }
python::pip { 'packaging' : ensure => '19.0', pkgname => 'packaging', }

But, I'm sure that upgrade is too big of change.

jeff1evesque avatar Oct 02 '19 00:10 jeff1evesque