voxpupuli / onceover

Your gateway drug to automated infrastructure testing with Puppet
Apache License 2.0
142 stars 45 forks source link

[bug] ruby error when running controlrepo_spec #5

Closed GeoffWilliams closed 8 years ago

GeoffWilliams commented 8 years ago

Overview

Ruby error encountered after copying in default config files from https://github.com/dylanratcliffe/puppet_controlrepo

Expected result

Tests should run or give actionable error

Actual result

geoff ~/github/r10k-control $ bundle exec rake controlrepo_spec
rake aborted!
TypeError: no implicit conversion of nil into String
/Library/Ruby/Gems/2.0.0/gems/controlrepo-2.0.1/lib/controlrepo.rb:260:in `r10k_config'
/Library/Ruby/Gems/2.0.0/gems/controlrepo-2.0.1/lib/controlrepo/testconfig.rb:108:in `r10k_deploy_local'
/Library/Ruby/Gems/2.0.0/gems/controlrepo-2.0.1/lib/controlrepo/rake_tasks.rb:87:in `block in <top (required)>'
Tasks: TOP => controlrepo_spec => controlrepo_autotest_prep
(See full trace by running task with --trace)

trace output

geoff ~/github/r10k-control $ bundle exec rake controlrepo_spec --trace
** Invoke controlrepo_spec (first_time)
** Invoke controlrepo_autotest_prep (first_time)
** Execute controlrepo_autotest_prep
rake aborted!
TypeError: no implicit conversion of nil into String
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/psych.rb:299:in `initialize'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/psych.rb:299:in `open'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/psych.rb:299:in `load_file'
/Library/Ruby/Gems/2.0.0/gems/controlrepo-2.0.1/lib/controlrepo.rb:260:in `r10k_config'
/Library/Ruby/Gems/2.0.0/gems/controlrepo-2.0.1/lib/controlrepo/testconfig.rb:108:in `r10k_deploy_local'
/Library/Ruby/Gems/2.0.0/gems/controlrepo-2.0.1/lib/controlrepo/rake_tasks.rb:87:in `block in <top (required)>'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:201:in `block in invoke_prerequisites'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:199:in `each'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:199:in `invoke_prerequisites'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:178:in `block in invoke_with_call_chain'
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/Library/Ruby/Gems/2.0.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/usr/bin/rake:23:in `load'
/usr/bin/rake:23:in `<main>'
Tasks: TOP => controlrepo_spec => controlrepo_autotest_prep
GeoffWilliams commented 8 years ago

Problem seems to be here:

  def r10k_config_file
    r10k_config_file = File.expand_path('./r10k.yaml',@spec_dir) if File.exist?(File.expand_path('./r10k.yaml',@spec_dir))
    r10k_config_file = File.expand_path('./r10k.yaml',@root) if File.exist?(File.expand_path('./r10k.yaml',@root))
    r10k_config_file
  end

  def r10k_config
    YAML.load_file(r10k_config_file)
  end

Can we live without an R10K config file and just process the Puppetfile?

GeoffWilliams commented 8 years ago

I propose fixing this one by doing a manual copy of the all the files in the control repo to the temp dir and then processing the Puppetfile. That way we don't need r10k config file at all.

In my own repository I have a bootstrap script that I can run but not everybody is going to want to do this. It should be possible to just process the Puppetfile in the current directory, like this https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#environment-variables

So if we do that and a copy we should be golden and not need r10k.conf at all

dylanratcliffe commented 8 years ago

Done