rodjek / librarian-puppet

http://librarian-puppet.com
MIT License
693 stars 209 forks source link

Librarian-puppet gets stuck on metadata.json #269

Closed engineerKev closed 9 years ago

engineerKev commented 9 years ago

I am using vagrant with puppet and librarian-puppet to set up a server on vagrant up. I cd into my project/puppet/ directory and do a librarian-puppet init, and chose not to over ride my Puppet file since I already have one, and have done librarian-puppet init before. I go to do a vagrant up and the whole process breaks when, I assume librarian-puppet is trying to add the modules. This is the output

==> default: [Librarian] Ruby Version: 2.1.4
==> default: [Librarian] Ruby Platform: x86_64-linux
==> default: [Librarian] Rubygems Version: 2.4.2
==> default: [Librarian] Librarian Version: 0.1.2
==> default: [Librarian] Librarian Adapter: puppet
==> default: [Librarian] Librarian Adapter Version: 2.0.0
==> default: [Librarian] Project: /home/vagrant
==> default: [Librarian] Specfile: Puppetfile
==> default: [Librarian] Lockfile: Puppetfile.lock
==> default: [Librarian] Git: /usr/bin/git
==> default: [Librarian] Git Version: 1.7.9.5
==> default: [Librarian] Git Environment Variables:
==> default: [Librarian]   (empty)
==> default: [Librarian] Specfile not found, using defaults: /home/vagrant/Puppetfile
==> default: [Librarian] Pre-Cached Sources:
==> default: /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/json/common.rb:155:in `initialize'
==> default: : 
==> default: A JSON text must at least contain two octets!
==> default:  (
==> default: JSON::ParserError
==> default: )
==> default:    from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/json/common.rb:155:in `new'
==> default:    from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/json/common.rb:155:in `parse'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:73:in `metadata'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:24:in `block in run'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl/receiver.rb:34:in `instance_eval'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl/receiver.rb:34:in `run'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:47:in `run'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:34:in `block in run'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:28:in `tap'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:28:in `run'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl.rb:17:in `run'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/environment.rb:148:in `dsl'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/specfile.rb:15:in `read'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/action/resolve.rb:13:in `run'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:169:in `resolve!'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/cli.rb:67:in `install'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `block (2 levels) in bin!'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:31:in `returning_status'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `block in bin!'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:47:in `with_environment'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `bin!'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/bin/librarian-puppet:7:in `<top (required)>'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/bin/librarian-puppet:23:in `load'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/bin/librarian-puppet:23:in `<main>'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/bin/ruby_executable_hooks:15:in `eval'
==> default:    from /usr/local/rvm/gems/ruby-2.1.4/bin/ruby_executable_hooks:15:in `<main>'
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

 chmod +x /tmp/vagrant-shell && /tmp/vagrant-shell

 Stdout from the command:

 [Librarian] Ruby Version: 2.1.4
 [Librarian] Ruby Platform: x86_64-linux
 [Librarian] Rubygems Version: 2.4.2
 [Librarian] Librarian Version: 0.1.2
 [Librarian] Librarian Adapter: puppet
 [Librarian] Librarian Adapter Version: 2.0.0
 [Librarian] Project: /home/vagrant
 [Librarian] Specfile: Puppetfile
 [Librarian] Lockfile: Puppetfile.lock
 [Librarian] Git: /usr/bin/git
 [Librarian] Git Version: 1.7.9.5
 [Librarian] Git Environment Variables:
 [Librarian]   (empty)
 [Librarian] Specfile not found, using defaults: /home/vagrant/Puppetfile
 [Librarian] Pre-Cached Sources:

 Stderr from the command:

    stdin: is not a tty
    /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/json/common.rb:155:in `initialize': A JSON text must at least contain two octets! (JSON::ParserError)
    from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/json/common.rb:155:in `new'
    from /usr/local/rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/json/common.rb:155:in `parse'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:73:in `metadata'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:24:in `block in run'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl/receiver.rb:34:in `instance_eval'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl/receiver.rb:34:in `run'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:47:in `run'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:34:in `block in run'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:28:in `tap'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/dsl.rb:28:in `run'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/dsl.rb:17:in `run'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/environment.rb:148:in `dsl'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/specfile.rb:15:in `read'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/action/resolve.rb:13:in `run'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:169:in `resolve!'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/lib/librarian/puppet/cli.rb:67:in `install'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `block (2 levels) in bin!'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:31:in `returning_status'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `block in bin!'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:47:in `with_environment'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `bin!'
    from /usr/local/rvm/gems/ruby-2.1.4/gems/librarian-puppet-2.0.0/bin/librarian-puppet:7:in `<top (required)>'
    from /usr/local/rvm/gems/ruby-2.1.4/bin/librarian-puppet:23:in `load'
    from /usr/local/rvm/gems/ruby-2.1.4/bin/librarian-puppet:23:in `<main>'
    from /usr/local/rvm/gems/ruby-2.1.4/bin/ruby_executable_hooks:15:in `eval'
    from /usr/local/rvm/gems/ruby-2.1.4/bin/ruby_executable_hooks:15:in `<main>'

I know the problem is with my metadata.json file, but that's just it. I don't know what I am supposed to do with my metadata.json. I put an empty set of curly braces in there since the mods are being pulled in by librarian puppet and read that the metadata.json file just has mods in it(I could be wrong). I also read that the metadata.json file is generated. However I do not see anything anywhere in librarian puppet instructions about how to generate the metadata.json, just that it can be used instead of your Puppetfile. Can anyone help point out what I am doing wrong here? I know I missed something but I don't see what! :-/. Thanks in advance for the help.

this is my PuppetFile:

#!/usr/bin/env ruby
#^syntax detection

forge "https://forgeapi.puppetlabs.com"

# use dependencies defined in metadata.json
metadata

 # use dependencies defined in Modulefile
# modulefile

# Java module
mod 'tylerwalts/jdk_oracle'

# A module from the Puppet Forge
# mod 'puppetlabs-stdlib'

# A module from git
# mod 'puppetlabs-ntp',
#   :git => 'git://github.com/puppetlabs/puppetlabs-ntp.git'

# A module from a git branch/tag
# mod 'puppetlabs-apt',
#   :git => 'https://github.com/puppetlabs/puppetlabs-apt.git',
#   :ref => '1.4.x'

# A module from Github pre-packaged tarball
# mod 'puppetlabs-apache', '0.6.0', :github_tarball => 'puppetlabs/puppetlabs-apache'
engineerKev commented 9 years ago

I've posted a similar, if not identical, question on stack over flow. I have gotten my modules to install, however; when puppet is provisioning it looks in the /tmp/vagrant-puppet-3 parent directory for the modules, manifests, and for the .pp file. I've ssh-ed into the box and checked if there are any modules in there and there aren't. Ironically, the directory /vagrant, in the box HAS the module directories in it. Should I just copy them over by adding the command in my librarian-puppet-init script or is there a specific thing I am missing that is preventing the modules from being installed in the vagrant-puppet-3/modules directory?

engineerKev commented 9 years ago

Thanks to the some help on stack overflow, by the same person that authored this git repo(I think). I was able to solve my problem. What it required was using the git command in the Puppetfile for all my modules, updating to the latest puppet, and also using Librarian-puppet's '--path' command to point to etc/puppet/librarian as the home of my modules as they were installed. Additionally I moved my Puppetfile into my 'puppet' dir on my local machine so that the modules would be installed inside puppet/modules on my local machine, on vagrant up. That's pretty much everything. Hope this helps. This issue is ready to be closed if need be

carlossg commented 9 years ago

For reference, you had multiple problems, an empty metadata.json file and no Puppetfile, running librarian in the wrong dir and not installing the modules in the path expected by puppet. I have improved the error message in the case the metadata.json doesn't parse

carlossg commented 9 years ago

Stackoverflow question http://stackoverflow.com/questions/26809553/vagrant-puppet-set-up-failing-to-find-class