Search code examples
vagrantpuppetvagrantfile

Include Vagrantfile or Puppet script from URL


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?


Solution

  • 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