Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yaml instead of Puppetfile? #174

Open
zachfi opened this issue Dec 19, 2020 · 5 comments
Open

Yaml instead of Puppetfile? #174

zachfi opened this issue Dec 19, 2020 · 5 comments

Comments

@zachfi
Copy link

zachfi commented Dec 19, 2020

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?

@xorpaul
Copy link
Owner

xorpaul commented Dec 21, 2020

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.

@zachfi
Copy link
Author

zachfi commented Dec 29, 2020

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.

@justinstoller
Copy link

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

@bkuebler
Copy link
Contributor

bkuebler commented Jan 7, 2022

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...

@zachfi
Copy link
Author

zachfi commented Jan 7, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants