g10k icon indicating copy to clipboard operation
g10k copied to clipboard

Some valid Ruby Puppetfiles are not interpreted

Open alex-harvey-z3q opened this issue 8 years ago • 12 comments

When executing g10k -puppetfile I get:

$ g10k -puppetfile 
Error: Missing :git url in ./Puppetfile for module ad line: mod 'ad',git: '[email protected]:FOO/puppet-ad',ref: 'master'

My Puppetfile has modules declared as:

mod 'ad',
  git: '[email protected]:FOO/puppet-ad',
  ref: 'master'
...

Workaround for me was to rewrite the Puppetfiles using a regexp:

:%s/^  \(...\): /  :\1 => 

alex-harvey-z3q avatar Jul 05 '17 14:07 alex-harvey-z3q

Oh, I've never seen that Puppetfile format to be honest.

I'm always looking at https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd

I don't know if I'm going to support that format.

I'd rather just use a YAML file or something similar.

xorpaul avatar Jul 05 '17 14:07 xorpaul

That's OK. This is very cool:

$ g10k -puppetfile 
Resolving Git modules (39/39) 2.436s [====================================================================] 100%
Synced ./Puppetfile with 39 git repositories and 0 Forge modules in 11.2s with git (10.8s sync, I/O 3.8s) and Forge (0.0s query+download, I/O 0.0s)

👍

alex-harvey-z3q avatar Jul 05 '17 14:07 alex-harvey-z3q

Puppetfile, by the way, is a Ruby DSL. mod is a method that optionally accepts a Hash of keys. Anything that is valid Hash syntax in Ruby is valid Puppetfile, http://breakthebit.org/post/8453341914/ruby-19-and-the-new-hash-syntax

alex-harvey-z3q avatar Jul 05 '17 15:07 alex-harvey-z3q

Yeah, which makes it difficult for any other language than Ruby to parse a Puppetfile. Trust me I know :grinning:

Same problem as #36

xorpaul avatar Jul 05 '17 15:07 xorpaul

Maybe you can take a ruby syntax parser, for example from grubby and get the real meaning out of it that way.

On the other hand, you would then have a ruby syntax parser and people would be able to write loops and stuff, which would open a whole new level of mess :D

Gibheer avatar Jul 05 '17 17:07 Gibheer

@alexharv074 11 seconds is too much for 39 modules (but perhaps you have a high latency to your git server, or you disabled hardlinks). Look at my logs. 113 module in 5 seconds: 2017-07-05 18:58:16,838 INFO Synced ./Puppetfile with 78 git repositories and 35 Forge modules in 5.8s with git (5.4s sync, I/O 0.2s) and Forge (1.5s query+download, I/O 0.0s)

maxadamo avatar Jul 05 '17 19:07 maxadamo

@xorpaul In ntnn/puppetfiler I've written some code which parses a puppetfile to yaml. One possibility to resolve issues like these could be to extract that functionality to its own gem and to use that in g10k, e.g. by distributing it in the same tarball.

Enabling you to remove the regexes parsing g10k with all their blind spots.

What do you think of that?

ntnn avatar Jul 07 '17 12:07 ntnn

I appreciate the suggestion, but bundling a ruby gem with g10k isn't really something that I want to do.

I'm testing a YAML based Puppetfile at the moment, which should resolve such issues.

xorpaul avatar Jul 11 '17 10:07 xorpaul

Not really sure how a YAML config file helps people who want to use this tool in the way that it is advertised, i.e. as a drop-in replacement for r10k. If the tool fails to read a Puppetfile, then it might be a useful alternative to r10k; but it is not a drop-in replacement. I for one would not be able to use it at all if it can't support real Puppetfiles because my code needs to be compatible with a real r10k.

alex-harvey-z3q avatar Jul 12 '17 05:07 alex-harvey-z3q

@alexharv074 The r10k Puppetfile format parsing will remain in g10k. I'm just testing if I can provide advanced features like variable interpolation more easily inside a YAML based Puppetfile.

xorpaul avatar Jul 12 '17 09:07 xorpaul

As some already mentioned the issue is that the Puppetfile supports ruby syntax and people are doing all kinds of wild things with it.

A very nice solution would be to simply provide a hook for executing a script between when the control repository is checked out and g10k deploys the modules. This way we can transform whatever logic was in that old Puppetfile and just generate one with it g10k understands.

ZeroPointEnergy avatar Sep 19 '18 14:09 ZeroPointEnergy

Just wanted to leave my 2 cents here that I also stumbled upon this by wondering what was wrong with my file when g10k claimed that Missing :git url in …. IMHO if g10k becomes more popular, and I guess it will, given that Puppetlabs now refer to it, many more people migrating from r10k will stumble over this.

kwisatz avatar Mar 08 '22 15:03 kwisatz