Include Vagrantfile or Puppet script from URL

157 views Asked by At

We would like to use a standard Vagrant configuration with a several people and for several projects. We now experience lots of updates in the Vagrant configuration, which makes it hard to keep every project up-to-date.

The perfect situation would be to use a Vagrantfile with only an include of a remote file (for example a URL on Github, the file can be public). Is this possible with the Vagrantfile or for the puppet manifest files?

2

There are 2 answers

0
Konstantin On BEST ANSWER

Vagrantfile is a Ruby file. You can write actual Ruby code and it will be executed.

Put something like

require "open-uri"

File.open('puppet_script.pp', 'w') do |f|
  f.write open("http://here.goes.url/to/the/script.pp").read 
end

before Vagrant.configure(2) do |config|

P.S. I suspect, that you want to download file only when provisioning is about to happen, so take a look at this question

0
BMW On

It is a solution, but I don't like the way @Alik provided.

I recommend to checkin all your codes to github (or others) directly with Vagrantfile and puppet codes.

For your developers, you need ask them to run git pull to get updated. It will be easier to manage the code changes

With puppet manifests files, you shouldn't change them frequently. Using hierarchy yaml files to provide different environment data for vagrant/dev/stag/prod will be very practical for most of projects.