voxpupuli / puppet-python

Puppet module for installing and managing Python, pip, virtualenvs and Gunicorn virtual hosts.
https://forge.puppetlabs.com/puppet/python
Apache License 2.0
199 stars 370 forks source link

Installing Python36 not idempotent #501

Open 00kfulton00 opened 4 years ago

00kfulton00 commented 4 years ago

Affected Puppet, Ruby, OS and module versions/distributions

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.

Dan33l commented 4 years ago

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

00kfulton00 commented 4 years ago

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
`
jeff1evesque commented 4 years ago

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.