rodjek / librarian-puppet

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

Point to local module/path (not a git repo) #281

Closed adamjk-dev closed 9 years ago

adamjk-dev commented 9 years ago

Is there a way to point a module to a local path for use, instead of going to a git repository? The use case would be to use a module source directory, and pull in external dependencies with metadata.json.

For instance, can we do:

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

metadata

mod "my_module",
  :path => "."

This would be useful with Vagrant and vagrant-librarian-puppet, so that you can have a Puppetfile which points to the local module you are working on and/or developing, and librarian-puppet pulls in the dependencies and vagrant would get the path to all of the modules.

If you are at all familiar with 'Berkshelf' for Chef, this is how it can operate. It can point to a module and just a local path on the filesystem (no need for a Git repo if you so choose).

The example in Berkshelf is this (http://berkshelf.com/):

source "https://supermarket.chef.io"

metadata

cookbook 'memcached'
cookbook 'nginx'
cookbook 'pvpnet', path: '/Users/reset/code/riot-cookbooks/pvpnet-cookbook'
cookbook 'mysql', git: 'git://github.com/opscode-cookbooks/mysql.git'
adamjk-dev commented 9 years ago

I noticed in other issues people have mentioned being able to do this (pointing to just a path, not a git repo).

But, when I run it, I keep getting issues:

Error: Could not resolve the dependencies.

Version: librarian-puppet v2.0.1

carlossg commented 9 years ago

you can use :path see https://github.com/rodjek/librarian-puppet/blob/master/README.md#example-puppetfile

adamjk-dev commented 9 years ago

So, I run 'librarian-puppet install' from within a puppet module directory called 'websphere_mq_client' with a Puppetfile like this:

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

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

metadata

mod 'websphere_mq_client', :path => "./"

This does not work "Could not resolve dependencies". Is this because it is getting into an infinite loop trying to bring in the dependencies from metadata.json and the current working directory (and hitting metadata.json again) or something? My metadata.json depends on puppetlabs-stdlib and nanliu-staging.

Thanks!

carlossg commented 9 years ago

using ./ doesn't look like a good idea debug output? versions?

adamjk-dev commented 9 years ago

librarian-puppet v2.0.1

librarian-puppet install --verbose
[Librarian] Ruby Version: 1.9.3
[Librarian] Ruby Platform: x86_64-darwin13.3.0
[Librarian] Rubygems Version: 2.4.1
[Librarian] Librarian Version: 0.1.2
[Librarian] Librarian Adapter: puppet
[Librarian] Librarian Adapter Version: 2.0.1
[Librarian] Project: /Users/kunk/src/cse/websphere_mq_client
[Librarian] Specfile: Puppetfile
[Librarian] Lockfile: Puppetfile.lock
[Librarian] Git: /usr/bin/git
[Librarian] Git Version: 1.9.3
[Librarian] Git Environment Variables:
[Librarian]   (empty)
[Librarian] Pre-Cached Sources:
[Librarian]   [:forge, "https://forgeapi.puppetlabs.com", {}]
[Librarian] Post-Cached Sources:
[Librarian]   [:forge, "https://forgeapi.puppetlabs.com", {}]
[Librarian]   [:path, ".", {}]
[Librarian] Analyzing spec and lock:
[Librarian]   Removed:
[Librarian]   ExplicitRemoved:
[Librarian]   Added:
[Librarian]     websphere_mq_client
[Librarian]   NonMatchingAdded:
[Librarian]     websphere_mq_client
[Librarian]   Changed:
[Librarian]   DeepKeep:
[Librarian]     nanliu-staging
[Librarian]     puppetlabs-stdlib
[Librarian]   ShallowStrip:
[Librarian] Resolving websphere_mq_client (>= 0) <.>
[Librarian]   Checking manifests
[Librarian]     Checking websphere_mq_client/0.1.0 <.>
[Librarian] Pre-Cached Sources:
[Librarian] Post-Cached Sources:
[Librarian]   [:forge, "https://forgeapi.puppetlabs.com", {}]
[Librarian]   [:path, ".", {}]
[Librarian]       Cycle with websphere_mq_client/0.1.0 <.>
[Librarian]       Backtracking from websphere_mq_client/0.1.0 <.>
[Librarian]   Failed to resolve websphere_mq_client (>= 0) <.>
Could not resolve the dependencies.
/Users/kunk/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/action/persist_resolution_mixin.rb:11:in `persist_resolution'
/Users/kunk/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/action/resolve.rb:27:in `run'
/Users/kunk/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/cli.rb:169:in `resolve!'
/Users/kunk/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/librarian-puppet-2.0.1/lib/librarian/puppet/cli.rb:67:in `install'
/Users/kunk/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
/Users/kunk/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
/Users/kunk/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
/Users/kunk/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
/Users/kunk/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `block (2 levels) in bin!'
/Users/kunk/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/cli.rb:31:in `returning_status'
/Users/kunk/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `block in bin!'
/Users/kunk/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/cli.rb:47:in `with_environment'
/Users/kunk/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/librarian-0.1.2/lib/librarian/cli.rb:26:in `bin!'
/Users/kunk/.rbenv/versions/1.9.3-p547/lib/ruby/gems/1.9.1/gems/librarian-puppet-2.0.1/bin/librarian-puppet:7:in `<top (required)>'
/Users/kunk/.rbenv/versions/1.9.3-p547/bin/librarian-puppet:23:in `load'
/Users/kunk/.rbenv/versions/1.9.3-p547/bin/librarian-puppet:23:in `<main>'
carlossg commented 9 years ago

You can't have ./ as path, you are basically creating a dependency on itself

Cycle with websphere_mq_client/0.1.0 <.>
adamjk-dev commented 9 years ago

Yeah, that seems to be the case. I just imagined that when you did a 'librarian-puppet install' from within a puppet module itself, it would throw each of those modules into ./modules or wherever the output directory is.

What I am looking for is a model to use puppet apply and vagrant for each puppet module we have. This way, when you run 'vagrant up', vagrant-librarian-puppet would push the current module and any dependent modules from metadata.json into the machine being provisioned and go from there. But, the issue is that there is no way to force the current module into the machine being provisioned as well (short of doing a VM synced folder or something hacky like that, but that doesn't really work well).

Is there any way to get this behavior from within a single puppet module? Or, does it have to be a Puppetfile from an external directory (if that makes sense)?

This workflow I am hoping to achieve works with Vagrant, vagrant-berkshelf, and berkshelf in the Chef world. I was hoping to replicate previous workflows I used with Chef in the Puppet world.

carlossg commented 9 years ago

There is https://github.com/mhahn/vagrant-librarian-puppet

adamjk-dev commented 9 years ago

Yeah, I tried that vagrant plugin for that purpose. But, since the 'librarian-puppet install' step doesn't put the current module in the output directory (i.e. puppet/modules), then it still doesn't work as I have suggested. At least that was the experience I had with it. I could not get it to recognize a module in the same directory and grab the external dependencies.

andresgutgon commented 6 years ago

I found an issue with pointing to local modules that are in your puppet repo. I was doing this in my Puppetfile:

# Puppetfile
mod 'andresgutgon-mymodule', path: './my-modules'

And librarian was installing my local module. But it had corrupted characters in generated files image ☝️ look at line 19

What solved my issue was doing what is on documentation , point to my repo with a path argument:

# Puppetfile
mod(
  'andresgutgon-mymodule',
  :git => "git://github.com/andresgutgon/my-puppetproject.git",
  :path: 'my-modules/mymodule'
)