本文介绍了如何使用 Vagrant box 打包文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我使用以下命令创建了一个 Vagrant 框:

So I created a Vagrant box with the following command:

vagrant package --base box_name_here --vagrantfile Vagrantfile --include manifests/

manifests/ 是一个包含 puppet 清单和一些子目录的目录,其中包含在配置过程中使用的一些文件.Puppet 在 Vagrantfile 中被调用如下:

manifests/ is a directory with a puppet manifest and some subdirectories with some files used during the provisioning process. Puppet is called in the Vagrantfile like so:

config.vm.provision :puppet do |puppet|
    puppet.manifests_path = "manifests"
    puppet.manifest_file  = "web-dev.pp"
end

当我浏览 Vagrant 创建的打包 .box 存档时,我看到位于 box_name_here.box/includes/manifests 的文件夹.但是,当我尝试运行 vagrant up 时会出现以下错误:

When I explore the packaged .box archive Vagrant creates, I see the folder located at box_name_here.box/includes/manifests. However, vagrant up dies with the following error when I try to run it:

为 Puppet 指定的清单路径不存在:c:/vagrant/manifests

文件在其他地方吗?

我看到了这个帖子:https://github.com/mitchellh/vagrant/issues/344

但答案有点不透明;我不太清楚如何将 modulepath 响应转换为我的 manifests_path 问题.

But the answer is a bit opaque; I don't quite know how to translate the modulepath response to my manifests_path problem.

我更改了 vagrantfile 以便该行读取

I altered the vagrantfile so that the line reads

puppet.manifests_path = "./manifests"

...但这并没有解决问题.我仍然收到相同的错误消息.

...but that did not correct the problem. I still get the same error message.

推荐答案

经过一些实验,答案显而易见:

After some experimentation, the incredibly obvious answer is:

puppet.manifests_path = File.expand_path("../manifests", __FILE__)

这篇关于如何使用 Vagrant box 打包文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 20:23