Search code examples
vagrantpuppet

how to override default values of a provisioner?


i have a Vagrant file with multiple provision blocks like this:

config.vm.provision "puppet" do |puppet|
    puppet.manifests_path = "puppet/manifests"
    puppet.module_path = "puppet/modules"
    puppet.manifest_file = "first.pp"
end

config.vm.provision "puppet" do |puppet|
    puppet.manifests_path = "puppet/manifests"
    puppet.module_path = "puppet/modules"
    puppet.manifest_file = "second.pp"
end

config.vm.provision "puppet" do |puppet|
    puppet.manifests_path = "puppet/manifests"
    puppet.module_path = "puppet/modules"
    puppet.manifest_file = "third.pp"
end

how can i eliminate the redundant puppet.manifest_pathand puppet.module_path?


Solution

  • Well, it walks like Ruby and talks like Ruby, so chances are you can

    %w{first second third}.each do |manifest|
      config.vm.provision "puppet" do |puppet|
        puppet.manifests_path = "puppet/manifests"
        puppet.module_path    = "puppet/modules"
        puppet.manifest_file  = "#{manifest}.pp"
      end
    end
    

    Note that you can specify a directory of manifests to be used, instead of a single file.