添加的框的版本始终为v0
;我怎样才能改变这个值?例如,当我执行vagrant box list
时,我的框始终是版本v0
。
我正在使用Packer创建一个VirtualBox Vagrant“框”,但我无法弄清楚如何设置框输出的版本。
Packer构建命令使用构建器JSON文件
$ packer build builder.json
...
==> virtualbox-iso (vagrant): Creating Vagrant box for 'virtualbox' provider
virtualbox-iso (vagrant): Copying from artifact: dist-28/ion-disk001.vmdk
virtualbox-iso (vagrant): Copying from artifact: dist-28/ion.ovf
virtualbox-iso (vagrant): Renaming the OVF to box.ovf...
virtualbox-iso (vagrant): Compressing: Vagrantfile
virtualbox-iso (vagrant): Compressing: box.ovf
virtualbox-iso (vagrant): Compressing: ion-disk001.vmdk
virtualbox-iso (vagrant): Compressing: metadata.json
并且上面的Packer步骤的输出是名为packer_virtualbox-iso_virtualbox.box
的Vagrant框,然后我使用
$ vagrant box add BOX_NAME packer_virtualbox-iso_virtualbox.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'BOX_NAME' (v0) for provider:
box: Unpacking necessary files from: file:///packer/packer_virtualbox-iso_virtualbox.box
==> box: Successfully added box 'BOX_NAME' (v0) for 'virtualbox'!
我想将值v0
更改为其他内容。这是builder.json
{
"builders": [
{
"type": "virtualbox-iso",
"vm_name": "ion-${ION_BUILD_NUMBER}",
"output_directory": "dist-${ION_BUILD_NUMBER}",
"iso_url": "${ISO_URL}",
"iso_checksum": "${MD5}",
...
}
],
"post-processors": [
"vagrant"
]
}
答案 0 :(得分:1)
已修复issue,因此您现在可以提供自己的metadata.json
文件
{
"name": "xxxx",
"description": "xxxx",
"versions": [
{
"version": "0.1.0",
"providers": [
{
"name": "virtualbox",
}
]
}
]
}
答案 1 :(得分:1)
我想我可以使用输出文件名作为版本号
"post-processors": [
{
"output": "box/vm-${ION_BUILD_NUMBER}.box",
"type": "vagrant"
}
]