2

I A have a Puppet module with acceptance tests based on Beaker. The module is working fine and when running locally all the acceptance tests run fine. But when I run the tests on Travis I got the following error in the module execution:

/Stage[main]/Alfred::Services/Service[alfred]: Could not evaluate: undefined method `[]' for nil:NilClass

Alfred is a system service based on upstart that is part of my module. I am using Puppet 4.3.2. Here is the travis build: https://travis-ci.org/nicopaez/alfred-puppet

Any idea?

NicoPaez
  • 426
  • 2
  • 12

1 Answers1

1

Looking at the code, there's a few issues.

One is that the environment variable you're using in Travis doesn't set the Puppet version. You need to add that code to your spec_helper_acceptance.rb:

hosts.each do |host|
  install_puppet_on(host,
    :puppet => ENV['PUPPET_VERSION'] || '4.3.2',
  )
end

Right now it's still installing Puppet 3.8 (the default latest)

For further information on what is actually causing the issues in Travis, I forked your repo and did a build where I enabled the debug and trace options for beaker:

result = apply_manifest(pp, :trace => true, :debug => true)

From this, looking at the Travis build, theres an issue with the git clone exec:

Debug: Exec[clone-repo](provider=posix): Executing 'git clone https://github.com/fiuba/alfred.git /var/www/alfred'
  Debug: Executing 'git clone https://github.com/fiuba/alfred.git /var/www/alfred'
  Notice: /Stage[main]/Alfred::App/Exec[clone-repo]/returns: fatal: Could not change back to '/root': Permission denied
  Error: git clone https://github.com/fiuba/alfred.git /var/www/alfred returned 128 instead of one of [0]

You could fix this by using the vcsrepo module, which performs git clones in an more idempotent way:

vcsrepo { '/var/www/alfred':
  ensure   => present,
  source   => 'https://github.com/fiuba/alfred.git',
  provider => git,
  user     => 'deployer',
}

There's a few other fixes, I'm PRing some fixes to your module to fix them, and will add a summary here to the Stack Overflow answer after you've reviewed and merged, as some are significant refactors with a few different approaches.

Peter Souter
  • 5,110
  • 1
  • 33
  • 62
  • Thanks @peter but I think you are working on master branch where the build works because the tests checks basic stuff. Please take a look at "fix-travis" branch where there are several tests and you will see the error I am reporting. – NicoPaez Apr 04 '16 at 00:45