voxpupuli / puppet-r10k

Setup and configure r10k for use with git based environments in puppet
https://forge.puppet.com/puppet/r10k
Apache License 2.0
98 stars 168 forks source link

Upgrade support for Puppet 5.0 #382

Open WetHippie opened 7 years ago

WetHippie commented 7 years ago

Affected Puppet, Ruby, OS and module versions/distributions

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

Upgrade of puppet 5.0 by use of puppetlabs/puppet_agent. Auto install of the latest version (after manually setting the new ::source)

What are you seeing

With the new version of puppet and ruby, the gem isn't installed to run r10k with on the command line (and similar when auto managed using this module)

/opt/puppetlabs/puppet/lib/ruby/2.4.0/rubygems/dependency.rb:308:in `to_specs': Could not find 'r10k' (>= 0) among 27 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/root/.gem/ruby/2.4.0:/opt/puppetlabs/puppet/lib/ruby/gems/2.4.0', execute `gem env` for more information
    from /opt/puppetlabs/puppet/lib/ruby/2.4.0/rubygems/dependency.rb:320:in `to_spec'
    from /opt/puppetlabs/puppet/lib/ruby/2.4.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
    from /bin/r10k:22:in `<main>'

What behaviour did you expect instead

Difficult to say other than "should make sure the new gem is auto installed with ruby 2.4. However, this is a chicken an egg situation in that ruby won't be installed until puppet is, and then once it is, puppet can't run in order to get r10k to update itself.

Output log

See above

Any additional information you'd like to impart

None.

rnelson0 commented 7 years ago

@WetHippie I can't upgrade to Puppet 5 w/ r10k myself (I'm a PE user) but can you share the manifest you're using to manage the r10k gem installation? I'm sure we can troubleshoot it with enough eyes on it.

WetHippie commented 7 years ago

I ended up getting stuck with a chicken and egg situation with the module and dependencies since I could not get r10k to run to pull in the new dependencies. I had to manually install the r10k gem from the command line, so I'm not much help either :(

On the command line I used

/opt/puppetlabs/puppet/bin/gem install r10k

and since the latest puppet server was already at 5.0.x, it placed the r10k installation into the right version of the ruby directory (in this case 2.4.0)

rnelson0 commented 7 years ago

@WetHippie I can't help with this right now, but we can leave it open in the hopes that someone else can either verify the problem and test some fixes, or determine that it was a one-off issue. Hopefully, the next PE edition with Puppet 5 in it launches soon, and then I might be able to help myself. Thanks!

rsynnest commented 6 years ago

@WetHippie I experienced the same issue after upgrading my puppet master from v4.10.12 to v5.5.6 yesterday on Ubuntu 16.04. Your workaround (/opt/puppetlabs/puppet/bin/gem install r10k) worked for me as well. I believe my original r10k install was via this method, which uses the same manual install command (/opt/puppetlabs/puppet/bin/gem install r10k), so I guess it makes sense that I would need to manually install r10k again after upgrading. Sounds like @rnelson's recommendation of installing r10k via Puppet may be better and would carry over a proper r10k version across upgrades?

kenyon commented 5 years ago

You need to use puppetserver_gem to have puppet install the r10k gem. https://forge.puppet.com/puppetlabs/puppetserver_gem

dhoppe commented 5 years ago

@kenyon Is this still necessary? Do we need to update the docs?

kenyon commented 5 years ago

@dhoppe I guess it's still necessary. This is what I do:

  Package['ruby'] -> Package <| provider == 'gem' |>

  # Ruby gems.
  lookup('gems', Array[String], 'unique').each |String $gem| {
    package { "gem_${gem}":
      ensure          => installed,
      provider        => gem,
      name            => $gem,
      install_options => ['--http-proxy', "http://${lookup('proxy.host')}:${lookup('proxy.port')}"],
    }
  }
class mysite::nodes::puppet (Array[String] $puppetserver_gems) {
  # Ruby gems for the puppetserver embedded Ruby environment.
  $puppetserver_gems.each |String $pkg| {
    package { "puppetserver_gem_${pkg}":
      ensure          => installed,
      provider        => puppetserver_gem,
      name            => $pkg,
      install_options => ['--http-proxy', "http://${lookup('proxy.host')}:${lookup('proxy.port')}"],
    }
  }
}

In hiera:

gems:
  - r10k

mysite::nodes::puppet::puppetserver_gems:
  - r10k