Nep*_*ich 17 deployment vagrant
我正试图用流浪汉自动化我的开发盒.我需要与其他开发人员共享流浪者设置,因此我们需要确保在正常vagrant up流程开始之前满足某些边界条件.
流浪汉中是否有任何钩子(如git,pre-commit或其他pre-*脚本)?提供脚本太晚了.
我目前的设置如下:
Vagrantfile
vagrant-templates/
vagrant-templates/apache.conf
vagrant-templates/...
sub-project1/
sub-project2/
Run Code Online (Sandbox Code Playgroud)
我需要确定,子项目{1..n}存在,如果不存在,则应该有错误消息.
我更喜欢类似bash的解决方案,但我对其他解决方案持开放态度.
Emy*_*myl 25
你可以试试我写的这个Vagrant插件:
https://github.com/emyl/vagrant-triggers
安装完成后,您可以在Vagrantfile中输入以下内容:
config.trigger.before :up, :execute => "..."
Run Code Online (Sandbox Code Playgroud)
tma*_*lai 11
一种选择是将逻辑直接放入Vagrantfile中.然后它将vagrant在项目中的所有命令上执行.例如这样的事情:
def ensure_sub_project(name)
if !File.exists?(File.expand_path("../#{name}", __FILE__))
# you could raise or do other ruby magic, or shell out (for a bash script)
system('clone-the-project.sh', name)
end
end
ensure_sub_project('some-project')
ensure_sub_project('other-project')
Vagrant.configure('2') do |config|
# ...
end
Run Code Online (Sandbox Code Playgroud)
小智 5
可以为vagrant编写自己的插件,并在machine_action_up上使用action_hook,如:
require 'vagrant-YOURPLUGINNAME/YOURACTIONCLASS'
module VagrantPlugins
module YOURPLUGINNAME
class Plugin < Vagrant.plugin('2')
name 'YOURPLUGINNAME'
description <<-DESC
Some description of your plugin
DESC
config(:YOURPLUGINNAME) do
require_relative 'config'
Config
end
action_hook(:YOURPLUGINNAME, :machine_action_up) do |hook|
hook.prepend(YOURACTIONCLASS.METHOD)
end
end
end
end
Run Code Online (Sandbox Code Playgroud)