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

ERB support is not working? #58

Open
walterheck opened this issue Dec 19, 2016 · 3 comments
Open

ERB support is not working? #58

walterheck opened this issue Dec 19, 2016 · 3 comments

Comments

@walterheck
Copy link

I can't get the erb parsing support implemented in #24 to work properly, is there something I'm missing?

I have this yaml:

---
roles:
  foss-puppet-master:
    provider:
      type: virtualbox
    provisioners:
      - type: shell
        path: files/setup.sh
        env:
          GIT_BRANCH: <%= ENV['GIT_BRANCH'] >

Which when called like this:

walterheck@walter-envy:~/source/opstheater/deploy/vagrant-oscar$ GIT_BRANCH=test vagrant provision foss-master
 WARN config_builder: The provider attribute, set on vm foss-master, is deprecated and will be removed in an upcoming release. Use the providers attribute instead.
==> foss-master: Running provisioner: hosts...
==> foss-master: Running provisioner: shell...
    foss-master: Running: /tmp/vagrant-shell20161219-24241-19kctso.sh
==> foss-master: blah
==> foss-master: GIT_BRANCH=<%= ENV['GIT_BRANCH'] >
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
@walterheck
Copy link
Author

setup.sh looks like this by the way:

echo "blah"
printenv | grep -i git
exit 1

@nanliu since you implemented this, can you explain how it should work?

@walterheck
Copy link
Author

Seems like it is indeed a bug (or at the very least unintended behaviour): the oscar.run method always calls ConfigBuilder like this:

ConfigBuilder.load(:yaml, :yamldir, config_dir)

Which means it won't ever use the yaml_erb parser. For now I hacked my Vagrantfile like so:

if defined? Oscar
  oscar_config = ConfigBuilder.load(:yaml_erb, :yamldir, './config')
  Vagrant.configure('2', &oscar_config)
end

@walterheck
Copy link
Author

Not really sure what the intended fix should be though? Should the ConfigBuilder be able to load a loader based on the file extension instead? So if I rename my roles.yaml to roles.yaml.erb it will pick it up? I don't think it should do the yaml_erb option by default neither.
One last option could be to patch Oscar's run command to add an optional parameter that specifies the loader?
@nanliu @adrienthebo @Sharpie opinions?

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

1 participant