Como instalar um gem Ruby no Arch Linux usando o Puppet?

4

Eu tenho o seguinte :

class travis_linter {
  include shell

  package { 'travis-lint':
    ensure   => latest,
    provider => gem,
  }
}

Quando eu tento testar teste , no entanto, recebo a seguinte saída do Puppet:

==> default: Debug: Executing: '/usr/bin/gem install --no-rdoc --no-ri travis-lint'
==> default: Error: Could not update: Execution of '/usr/bin/gem install --no-rdoc --no-ri travis-lint' returned 1: ERROR:  While executing gem ... (TypeError)
==> default:     wrong argument type nil (expected Regexp)
==> default: Error: /Stage[main]/Travis_linter/Package[travis-lint]/ensure: change from absent to latest failed: Could not update: Execution of '/usr/bin/gem install --no-rdoc --no-ri travis-lint' returned 1: ERROR:  While executing gem ... (TypeError)
==> default:     wrong argument type nil (expected Regexp)

Outra saída possivelmente relevante do arquivo de log completo :

Debug: Puppet::Type::Package::ProviderPuppet_gem: file /opt/puppetlabs/puppet/bin/gem does not exist
Debug: /Package[puppet-lint]: Provider gem does not support features virtual_packages; not managing attribute allow_virtual
Debug: /Package[reek]: Provider gem does not support features virtual_packages; not managing attribute allow_virtual
Debug: /Package[travis-lint]: Provider gem does not support features virtual_packages; not managing attribute allow_virtual

Usar exec (com --backtrace e --debug ) em vez de package resulta no mesmo erro:

==> default: Debug: Executing: '/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: NOTE:  Debugging mode prints all exceptions even when rescued
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: Exception 'ArgumentError' at /usr/lib/ruby/2.3.0/rubygems.rb:498 - couldn't find HOME environment -- expanding '~'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: Exception 'LoadError' at /usr/lib/ruby/2.3.0/resolv.rb:171 - LoadError
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: Exception 'Resolv::DNS::Config::NXDomain' at /usr/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: Exception 'Resolv::DNS::Config::NXDomain' at /usr/lib/ruby/2.3.0/resolv.rb:549 - _rubygems._tcp.api.rubygems.org.vagrant.vm
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: Exception 'Resolv::ResolvError' at /usr/lib/ruby/2.3.0/resolv.rb:494 - DNS result has no information for _rubygems._tcp.api.rubygems.org
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: Exception 'TypeError' at /usr/lib/ruby/2.3.0/rubygems/installer.rb:674 - wrong argument type nil (expected Regexp)
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: ERROR:  While executing gem ... (TypeError)
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:     wrong argument type nil (expected Regexp)
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/installer.rb:674:in 'sub'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/installer.rb:674:in 'check_that_user_bin_dir_is_in_path'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/installer.rb:180:in 'initialize'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/installer.rb:104:in 'new'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/installer.rb:104:in 'at'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/request_set.rb:163:in 'block in install'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/request_set.rb:151:in 'each'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/request_set.rb:151:in 'install'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:250:in 'install_gem'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:300:in 'block in install_gems'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:296:in 'each'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:296:in 'install_gems'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/commands/install_command.rb:203:in 'execute'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/command.rb:308:in 'invoke_with_build_args'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/command_manager.rb:169:in 'process_args'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/command_manager.rb:139:in 'run'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/lib/ruby/2.3.0/rubygems/gem_runner.rb:55:in 'run'
==> default: Notice: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns:   /usr/bin/gem:21:in '<main>'
==> default: Error: /usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint returned 1 instead of one of [0]
==> default: Error: /Stage[main]/Travis_linter/Exec[/usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint]/returns: change from notrun to 0 failed: /usr/bin/gem install --no-rdoc --no-ri --backtrace --debug travis-lint returned 1 instead of one of [0]

Eu posso executar o mesmo comando manualmente:

[vagrant@archlinux ~]$ /usr/bin/gem install --no-rdoc --no-ri travis-lint
Fetching: travis-lint-2.0.0.gem (100%)
WARNING:  You don't have /home/vagrant/.gem/ruby/2.3.0/bin in your PATH,
          gem executables will not run.
Successfully installed travis-lint-2.0.0
1 gem installed

Ditto em um shell de raiz :

[vagrant@archlinux ~]$ sudo -s
root@archlinux:/home/vagrant# /usr/bin/gem install --no-rdoc --no-ri travis-lint
WARNING:  You don't have /root/.gem/ruby/2.3.0/bin in your PATH,
          gem executables will not run.
Successfully installed travis-lint-2.0.0
1 gem installed

e idem em sh :

[vagrant@archlinux ~]$ sudo sh
sh-4.3# /usr/bin/gem install --no-rdoc --no-ri travis-lint
WARNING:  You don't have /root/.gem/ruby/2.3.0/bin in your PATH,
          gem executables will not run.
Successfully installed travis-lint-2.0.0
1 gem installed

Há algo errado em executar gem 2.5.1 com Puppet 4.3.1 / 4.3.2 ?

Finalmente, algumas descobertas ! Parece gem install em um ambiente sem a variável HOME definida falhará :

unless !Gem.win_platform? && (path.include? user_bin_dir.sub(ENV['HOME'], '~'))

A solução alternativa:

exec { '/usr/bin/gem install --no-rdoc --no-ri travis-lint':
  environment => 'HOME=/root';
}
    
por l0b0 03.01.2016 / 01:04

0 respostas