Closed nanliu closed 10 years ago
Not sure if there's a better solution (or if I'm using this plugin wrong). This would allow something like:
---
provisioner:
- type: puppet
manifest_file: <%= ENV['VAGRANT_MANIFEST'] || 'init.pp' >
I would rather ERB interpolated YAML be implemented as a separate loader; the loader layer is entirely pluggable so you can easily implement elaborate loaders without having to change the core implementations.
For that matter, you could add a custom loader that inherits from the YAML loader, override that one method, and be done with that. However I don't want this to be a core behavior of the YAML loader.
Sure, I updated the PR.
Also, one of the purposes of this plugin was to get away from intertwined logic and data. If you need functionality like this, why not use a stock Vagrantfile?
Originally I was using a stock Vagrantfile, then I wrote a wrapper to simplify the VM specification, but it was a bit clunky. The more I updated the wrapper, the closer it looked like something like this, so I thought it would be easier to add a few small things to this project. I really don't need to tweak the rest of the VM configuration, except occasionally the puppet agent environment or the puppet manifest file name.
I also believe that one of the driving purposes behind config_builder
is to provide a logic-less way of configuring Vagrant. However, thhat does not have to preclude having an ERB layer that re-introduces logic --- as long as the two remain clearly and cleanly separated into different loaders.
Yep, the PR was rewritten so the erb loader is yaml_erb, and the original yaml loader is left as is.
Okay, I'm :+1:. Since this isn't as straightforward as pure YAML could you add some documentation to the class demonstrating the interpolation? Your first comment in this thread would be a great example of that.
@adrienthebo, I've made some updates to the PR. Let me know what you think. I'll write another PR to update the project documentation (README, etc).
Thanks for the contribution!
The yaml configuration files are processed by ERB first. This allows slightly more dynamic configs, such as support of environment variables for vagrant vm/provisioner settings: