vagrant - 使用 Vagrant 运行特定的 provision block

标签 vagrant chef-infra

我想在新配置的服务器上的 Vagrant 文件中运行一个单独的配置 block 。目前,当我从我的 CI 服务器运行它时

vagrant up

以下 block 执行成功

config.vm.provider :linode do |provider, override|   
    #creates a new instance etc .. the following block runs on this instance
end
config.vm.provision :chef_solo do |chef|
    chef.provisioning_path = "/tmp/deploy"
    chef.cookbooks_path = ["cookbooks"]
    chef.add_recipe = "mydeployagent" 
end

现在我想在之后运行一个单独的供应商。 (CI 服务器中的一个单独任务)即

config.vm.provision :chef_solo do |chef|
    chef.provisioning_path = "/tmp/deploy"
    chef.cookbooks_path = ["cookbooks"]
    chef.add_recipe = "mydeploydatabaseagent" 
end

我想弄清楚我需要什么

  1. 运行 vagrant up 以便它只执行第一个配置 block

  2. 运行 vagrant,这样它只会在 1 中创建的实例上运行第二个供应 block 。

提前致谢

最佳答案

来自 Vagrant docs .

Vagrant.configure("2") do |config|
  # ... other configuration

  config.vm.provision "bootstrap", type: "shell" do |s|
    s.inline = "echo hello"
  end
end

The --provision-with flag can be used if you only want to run a specific provisioner if you have multiple provisioners specified. For example, if you have a shell and Puppet provisioner and only want to run the shell one, you can do vagrant provision --provision-with shell. The arguments to --provision-with can be the provisioner type (such as "shell") or the provisioner name (such as "bootstrap" from above).

关于vagrant - 使用 Vagrant 运行特定的 provision block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29585670/

相关文章:

chef-infra - 测试厨房 1.4.2 初始设置消息 : Could not load the 'ssh' driver from the load path

chef-infra - 人们如何测试opsworks Recipe ?

ssh - 如何在Chef中修复 'knife bootstrap ssh connection to client issue'?

windows - 使用厨房收敛。异常 : VirtualBox requires that the same user be used to manage the VM that was created

在 Vagrant 机器中,如果没有 sudo,Git 命令将无法工作

macos - vagrant-coreos 图像在重启时在 OS X 的 virtualbox 4.3.2 中删除共享文件夹

ruby - 是否可以在 Vagrant 完成所有配置后在虚拟机上运行脚本?

macos - 在 Mac 上卸载 vagrant

ruby - 使用 yaml 文件启动 Vagrant 时出现意外错误

linux - Linux 的基于文本的配置管理器