xorpaul/g10k

Yaml instead of Puppetfile?

Opened this issue · 5 comments

I'm currently using r10k to the Puppetfile to read a yaml file and run the module install. But would it be possible for this utility to read the the yaml directly? Perhaps we just need a structure to read. I have another process that updates the yaml directly, which is easier to do than updating the Puppetfile. Is this possible today?

I don't quite understand your first sentence. What are you doing with r10k and a Yaml file?

If you mean if g10k currently supports a Puppetfile.yml equivalent to the normal Puppetfile, then the answer is no.
But I do have a local branch trying to add this to g10k.
So maybe early next year this could become supported.

Maybe a little example helps. Here is the full content of my Puppetfile:

require 'yaml'

datapath = File.expand_path('modules.yaml', File.join(__FILE__, '..'))

modules = YAML.load_file(datapath)

@data = []

modules.each do |m|
  name = m['name']
  opts = {}

  m.each do |k, v|
    opts[k.to_sym] = v if k.to_sym != :name
  end

  mod(name, opts)
end

So basically I'm loading the data from a yaml file and then executing a mod on each of them. I think I got the idea from here: puppetlabs/r10k#380

I didn't know about Puppetfile.yml though, perhaps that's what I should be looking at instead. My original question was mostly can we just load a yaml file with the data needed by g10k and skip the Puppetfile entirely. Really I just want to use Yaml for all module information, or some other structured format that isn't ruby, etc.

This isn't quite what you're looking for, but r10k has the ability to determine what environments exist and what modules should be in each environment through either a yaml file, a directory of yaml files, or an executable that returns the content expected on stdin. It's still experimental. Though if you implement a Puppetfile.yaml it might be useful to re-use the format?

See https://github.com/puppetlabs/r10k/blob/main/doc/dynamic-environments/configuration.mkd#experimental-features

I think the above one is a hack you can do because the Puppetfile is interpreted by r10k as ruby. Maybe this is not a good idea to do that and implement such thing. Because g10k is written in go otherwise you have to implement a crazy thing like parse Pupetfile with ruby in golang... definetly not recommend this here...

I don't think ruby needs to be part of the solution at all, if it were taken on. Mostly this would just be another file format in yaml to contain the list of modules.