Vagrant Triggers with $script

297 views
Skip to first unread message

Noah O'Donoghue

unread,
Mar 25, 2019, 12:05:31 AM3/25/19
to Vagrant
Hi,

I'm trying to work out the syntax for using a multiline variable with Vagrant triggers.

Following the example here:


Looking at the example:

$script = <<-SCRIPT
echo I am provisioning...
date > /etc/vagrant_provisioned_at
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.provision "shell", inline: $script
end

 This works great if I run
config.vm.provision "shell", inline: $script

but say I want to run it like this:
        trigger.run_remote = inline: $script

I get the error:
syntax error, unexpected ':', expecting keyword_end

EG:
  
    $script = <<-SCRIPT      
 
  echo I am provisioning...
  date > /etc/vagrant_provisioned_at
    SCRIPT

    machine.trigger.before :provision do |trigger|
        trigger.run_remote = inline: $script
    end

Anyone know the correct syntax for triggers?

Brian Cain

unread,
Mar 25, 2019, 11:28:41 AM3/25/19
to vagra...@googlegroups.com
Hey there!

You are missing brackets for the run_remote option. It is slightly different in that fact, but otherwise the options should be very close or the same. I recommend looking at the trigger documentation


The usage docs also have examples of how to use them

Thanks!

--
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/ce818b86-ad5a-437b-bbd2-067d5f42be72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Brian Cain

Noah O'Donoghue

unread,
Mar 25, 2019, 11:34:48 PM3/25/19
to vagra...@googlegroups.com
Thanks Brian!!

trigger.run_remote = {inline: $script} appears to work fine :)

Reply all
Reply to author
Forward
0 new messages