I found an acceptable workaround:
$facts =<<SET_FACTS
set -x
mkdir -p /etc/facter/facts.d
echo role=$1 > /etc/facter/facts.d/role.txt
echo location=$2 > /etc/facter/facts.d/location.txt
echo environment=$3 > /etc/facter/facts.d/environment.txt
SET_FACTS
module Vagrant
module Config
module V2
class Root
def provision(role, location, environment)
vm.provision "set-facts",
type: :shell,
inline: $facts,
args: [role, location, environment].map { |x|
x.to_s }
vm.provision :puppet do |puppet|
puppet.manifest_file = "site.pp"
puppet.module_path = ["modules", "internal"]
puppet.hiera_config_path = "hiera.yaml"
end
end
end
end
end
end
Vagrant.configure(2) do |config|
config.vm.box = "centos-6.6"
config.vm.synced_folder "hiera", "/etc/puppet/hiera"
config.vm.define :foo1 do |c|
c.vm.hostname = "foo-1.vagrant"
c.provision(:foo, :testing, :stage)
end
config.vm.define :bar1 do |c|
c.vm.hostname = "bar-1.vagrant"
c.provision(:bar, :testing, :stage)
end
end
On Wednesday, 16 September 2015 15:19:44 UTC+1, [email protected] wrote:
>
> Hi! I'm new here.
>
> Is it possible to reverse the order of provisioners from innermost to
> outermost when using a multi-machine setup? I want a small shell
> provisioner to create some facts in /etc/facter/facts.d/ before
> provisioning with puppet, to mimic our current setup as much as possible.
> (I have inherited a large puppet repo and am trying to create a Vagrant
> testbed for it before I start doing changes.)
>
> The puppet settings are the same for every box, but requires the shell
> provisioner to run first. Here's an example Vagrantfile to show what I want
> to do (some names changed to protect the innocent):
>
> $facts =<<FACTS
> set -x
> mkdir -p /etc/facter/facts.d
> echo foo_role=$1 > /etc/facter/facts.d/role.txt
> echo foo_location=$2 > /etc/facter/facts.d/location.txt
> echo foo_environment=$3 > /etc/facter/facts.d/environment.txt
> FACTS
>
> Vagrant.configure(2) do |config|
> config.vm.box = "centos-6.6"
> config.vm.synced_folder "hiera", "/etc/puppet/hiera"
>
> config.vm.provision :puppet do |puppet|
> puppet.manifest_file = "site.pp"
> puppet.module_path = ["modules", "internal"]
> puppet.hiera_config_path = "hiera.yaml"
> puppet.options = "--test"
> end
>
> config.vm.define :foo1 do |c|
> c.vm.hostname = "foo-1.vagrant"
> c.vm.provision :shell, inline: $facts, args: "foo testing stage"
> end
>
> config.vm.define :bar do |c|
> c.vm.hostname = "bar-1.vagrant"
> c.vm.provision :shell, inline: $facts, args: "bar testing stage"
> end
>
> # ... more machines omitted ...
>
> end
>
> If that's not possible, is there a way to "macroify" the puppet setup so I
> can add it as a single line to each defined machine? (I am not not familiar
> with the terminology in Ruby nor Vagrant.) Any other suggestions welcome.
>
> Stig
>
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of
those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vagrant-up/7634b850-f4ee-4acd-b1ce-4bed3c7b7d79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.