[英]How to set the version number of a Vagrant box using a Packer build?
添加的框的版本始終為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
$ 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"
]
}
我想我可以使用輸出文件名作為版本號
"post-processors": [
{
"output": "box/vm-${ION_BUILD_NUMBER}.box",
"type": "vagrant"
}
]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.