Use Vagrant trigger to execute bash script on host

I use Vagrant to run my test environment. Unfortunately, I have to get information (passwords) before deploying my stray mailbox. So far I am using Vagrant-Triggers for this and have several run "do something" commands.

IS

 [:up, :provision].each do |cmd| config.trigger.before cmd, stdout: true do run "rm -rf #{cookbooks_path}" run "mkdir -p #{cookbooks_path}" run "touch fileX" run "touch fileY" run "touch fileZ" end end 

How can I move all my commands into one batch file, which I then only include?

SHOULD

 [:up, :provision].each do |cmd| config.trigger.before cmd, stdout: true do include_script "Vagrant_trigger_before.sh" end end 

Thank you for your help!

+5
source share
1 answer

You can run the script directly using the run commands

 [:up, :provision].each do |cmd| config.trigger.before cmd, stdout: true do run "Vagrant_trigger_before.sh" end end 
+3
source

Source: https://habr.com/ru/post/1262346/


All Articles