本文介绍了在 Vagrantfile 中需要一个 Vagrant 插件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设执行 Vagrantfile 需要安装特定的 Vagrant 插件.所以,基本上你需要做的是

Supposed execution of a Vagrantfile requires a specific Vagrant plugin to be installed. So, basically what you need to do is

$ vagrant plugin install foobar-plugin
$ vagrant up

如果跳过第一步,vagrant up 会失败.

If you skip the first step, vagrant up fails.

Vagrant 中是否有一个选项可以让它自动安装插件?换句话说:是否可以在 Vagrantfile 中指定在创建和启动机器之前自动安装哪些插件?

Is there an option in Vagrant to make it install the plugin automatically? In other words: Is it possible to specify within a Vagrantfile which plugins to install automatically before creating and booting up the machine?

推荐答案

2019 更新:Vagrant 现在具有通过 Vagrantfile 要求插件的功能:

2019 Update: Vagrant now has functionality to require plugins through the Vagrantfile via:

Vagrant.configure("2") do |config|
  config.vagrant.plugins = "vagrant-some-plugin"

  # or as array:
  config.vagrant.plugins = ["vagrant-some-plugin", "vagrant-some-other-plugin"]

  # or as hash
  config.vagrant.plugins = {"vagrant-some-plugin" => {"version" => "1.0.0"}}
end

如果 Vagrant 检测到尚未安装插件,它会提示用户自行安装:

If Vagrant detects there are plugins not already installed it will prompt the user to install them itself:

$ vagrant up
Vagrant has detected project local plugins configured for this
project which are not installed.

  vagrant-some-plugin
Install local plugins (Y/N) [N]: y
Installing the 'vagrant-some-plugin' plugin. This can take a few minutes...
Fetching vagrant-some-plugin-1.0.0.gem
Installed the plugin 'vagrant-some-plugin (1.0.0)'!


Vagrant has completed installing local plugins for the current Vagrant
project directory. Please run the requested command again.

参见 https://www.vagrantup.com/docs/vagrantfile/vagrant_settings.html

这篇关于在 Vagrantfile 中需要一个 Vagrant 插件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 20:18