rubyrubygemspuppetr10k

R10K module get wrong ruby version when tries to install gem r10k


I'm trying to deploy the r10k using the module on puppetforge puppet-r10k r10k, but it seems that when I run puppet agent -t the module gets the wrong version that it is installed on the machine. The error:

Error: Execution of '/opt/puppetlabs/puppet/bin/gem install --no-document --no-document r10k' returned 1: ERROR:  Error installing r10k:
    The last version of faraday-net_http (>= 2.0, < 3.2) to support your Ruby & RubyGems was 3.0.2. Try installing it with `gem install faraday-net_http -v 3.0.2` and then running the current command again
    faraday-net_http requires Ruby version >= 3.0.0. The current ruby version is 2.7.8.225.
Error: /Stage[main]/R10k::Install/Package[r10k]/ensure: change from 'absent' to 'present' failed: Execution of '/opt/puppetlabs/puppet/bin/gem install --no-document --no-document r10k' returned 1: ERROR:  Error installing r10k:
    The last version of faraday-net_http (>= 2.0, < 3.2) to support your Ruby & RubyGems was 3.0.2. Try installing it with `gem install faraday-net_http -v 3.0.2` and then running the current command again
    faraday-net_http requires Ruby version >= 3.0.0. The current ruby version is 2.7.8.225.

Current version on the machine:

root@mpuppetserver:~# ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]

I tried to install (as he says) the faraday-net_http -v 3.0.2 but this doesn't resolve the problem. I tried anyway to add different sources and remote repository (Hiera):

r10k::sources:
  preprod:
    remote: "%{lookup('git_preprod')}"
    basedir: "${::settings::codedir}/environments"
    prefix: false

and it seems to be able to skip the error and add the data into the file /etc/puppetlabs/r10k/r10k.yaml:

root@puppetserver:~# cat /etc/puppetlabs/r10k/r10k.yaml
---
pool_size: 6
deploy:
  generate_types: true
  exclude_spec: true
cachedir: "/opt/puppetlabs/puppet/cache/r10k"
sources:
  preprod:
    remote: git@blabla/bla.git
    basedir: "${::settings::codedir}/environments"
    prefix: false

Btw the error remains and doesnt install the r10k gem.

Thank you.


Solution

  • The gem must be installed with the Puppet Server's C/MRI interpreter Ruby installation, and not the system installation of Ruby, nor the JRuby Puppet Server installation:

    /opt/puppetlabs/puppet/bin/gem install --no-document faraday-net_http -v 3.0.2
    

    This will resolve the error, and you will be able to proceed.