On Tue, Feb 11, 2020 at 12:29 PM Steve Freeman <freeman...@gmail.com> wrote:
> I'm trying to write out a configuration file based on the state of > execution at that point in the overall provisioning process. If I don't > use a trigger, then the code will execute the code to write the file with > different parameters while the Vagrantfile is being evaluated. The > resulting file is the last one generated. The file isn't just a handful of > properties to be written or I'd pass the values as arguments and write the > file locally in the provisioning script. > > Here is what I'd like to be able to do: > > config.trigger.before [:up,:provision], :provisioner_name => > "install" do |trigger| > trigger.info = "Generate install configuration" > trigger.ruby do |env, machine| > puts "generating configuration for > #{json['version'][0]}" > generate_configuration( json, baseOS, node_name ) > end > end > You can write a trigger that runs before a given Vagrant hook, i.e. before the provision step: https://www.vagrantup.com/docs/triggers/usage.html#hooks Please note the additional *type* option that defines this trigger as a hook. config.trigger.before :provisioner_run, type: :hook do |t| t.info = "Before the provision!" t.ruby do |env,machine| puts "ruby stuff!" generate_stuff() endend > > > On Tuesday, February 11, 2020 at 3:21:53 PM UTC-5, Brian Cain wrote: >> >> Hey Steve - >> >> On Tue, Feb 11, 2020 at 8:10 AM Steve Freeman <free...@gmail.com> wrote: >> >>> I have a shell provisioners specified with names, like so: >>> >>> config.vm.provision "disk", type: "shell", path: "provision.ps1" >>> >>> How do I get a trigger to execute specific code only before this >>> particular provisioner? >>> >> >> What kind of trigger are you writing? If it's just a trigger that runs on >> the guest, the easiest thing to do >> would be to use a regular provisioner instead. >> >> >>> -- >>> 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 vagra...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/vagrant-up/416eb13e-c41c-40cc-97f2-cfadd64eb1f1%40googlegroups.com >>> <https://groups.google.com/d/msgid/vagrant-up/416eb13e-c41c-40cc-97f2-cfadd64eb1f1%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> >> >> -- >> Brian Cain >> > -- > 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 vagrant-up+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/vagrant-up/446d83dc-2dbf-4bc8-8fcc-0a5fc2f711ed%40googlegroups.com > <https://groups.google.com/d/msgid/vagrant-up/446d83dc-2dbf-4bc8-8fcc-0a5fc2f711ed%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Brian Cain -- 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 vagrant-up+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CADHESCUxc5PJOyJE7OL9ONFLRN-0%3D%2BLeZ4XBdk5%3D-U6dRhC4MQ%40mail.gmail.com.