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

Add configuration option for user Vagrantfiles #112

Closed
wants to merge 4 commits into from
Closed

Add configuration option for user Vagrantfiles #112

wants to merge 4 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jul 29, 2014

This adds a config option, 'vagrantfiles', that takes an arbitrary list of relative or absolute paths to Vagrantfiles and merges them with the generated Vagrantfile.

Internally, the list of Vagrantfile paths is converted to absolute paths and then to paths relative to the generated Vagrantfile.

@ghost
Copy link
Author

ghost commented Jul 29, 2014

And I'm immediately questioning the usefulness of converting the paths from absolute back to relative...

@sethvargo
Copy link
Contributor

👍

@@ -1,3 +1,9 @@
<% config[:vagrantfiles].each do |vagrantfile|
#REVIEW: should this check for file existance or fail?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sethvargo I wasn't sure if you had a reason for checking the file's existence in your example. My thought is that the user should be informed if their Vagrantfiles are missing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ummm, yea, you're probably right

@gkra
Copy link

gkra commented Aug 8, 2014

@byggztryng Given a cookbook, with .kitchen.yml in the cookbook root, would entries for vagrantfiles be relative to the .kitchen.yml, or some other path? This is unclear. When I have this in my .kitchen.yml:

---
driver:  
  name: vagrant
  vagrantfiles: 
    - .vagrant.custom

I get this error when I try to kitchen create:

---- Begin output of vagrant up --no-provision --provider=virtualbox ----
STDOUT:
STDERR: There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: /Users/gruiz-ade/tmp/mycookbook/.kitchen/kitchen-vagrant/default-centos-65/Vagrantfile
Message: cannot load such file -- /.vagrant.custom
---- End output of vagrant up --no-provision --provider=virtualbox ----

My .kitchen.yml

$ pwd
/Users/gruiz-ade/tmp/mycookbook
$ ls .kitchen.yml .vagrant.custom
.kitchen.yml  .vagrant.custom

So, obviously I'm missing something, right?

@ghost
Copy link
Author

ghost commented Aug 12, 2014

@gkra sorry for the delay. Could you try again with a non hidden Vagrantfile (remove the leading dot)?

@gkra
Copy link

gkra commented Aug 14, 2014

Same result.

gruiz-ade@gopher-active(ttys003):mycookbook 120 $ head .kitchen.yml
---
driver:
  name: vagrant
  customize:
    memory: 512
    vagrantfiles:
      - Vagrantfile.kitchen

provisioner:
  name: chef_zero

gruiz-ade@gopher-active(ttys003):mycookbook 121 $ cat Vagrantfile.kitchen
Vagrant.configure("2") do |config|
  config.vm.box_download_insecure = true
end

gruiz-ade@gopher-active(ttys003):mycookbook 122 $ bundle exec kitchen create default-centos-65
-----> Starting Kitchen (v1.2.1)
-----> Creating <default-centos-65>...
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: Failed to complete #create action: [Expected process to exit with [0], but received '1'
---- Begin output of vagrant up --no-provision --provider=virtualbox ----
STDOUT:
STDERR: There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: /Users/gruiz-ade/tmp/mycookbook/.kitchen/kitchen-vagrant/default-centos-65/Vagrantfile
Message: cannot load such file -- /Vagrantfile.kitchen
---- End output of vagrant up --no-provision --provider=virtualbox ----
Ran vagrant up --no-provision --provider=virtualbox returned 1]
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

gruiz-ade@gopher-active(ttys003):mycookbook 123 $

@ghost
Copy link
Author

ghost commented Aug 16, 2014

@gkra okay, thanks. There's clearly a bug that's always resolving the path to be from /, which is strange because I did test this successfully. I'll have a look.

@ghost
Copy link
Author

ghost commented Aug 17, 2014

@gkra feel free to give it a try now; I've updated the README with an explanation, too.

@gkra
Copy link

gkra commented Sep 11, 2014

Finally had a chance to test this, works for me exactly as I'd hoped. 👍

@ghost
Copy link
Author

ghost commented Sep 11, 2014

@gkra Excellent, thanks!

@sax
Copy link

sax commented Nov 8, 2014

Any consideration on merging this? It seems like it would solve #97.

sethvargo added a commit that referenced this pull request Nov 10, 2014
Add configuration option for user Vagrantfiles
@sethvargo
Copy link
Contributor

Merged in b4ee172. Thanks!

@sethvargo sethvargo closed this Nov 10, 2014
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

Successfully merging this pull request may close these issues.

3 participants