是否可以通过脚本检查Vagrant框是否已过期?

时间:2015-12-07 05:42:06

标签: windows macos scripting vagrant

我的团队正在使用Vagrant,每当有新盒子出现时,我们都希望更新以保持最新状态。我们不关心新版本的盒子是个问题。

因此,我希望创建一个脚本(在Windows和Mac上,是的,它可能是不同的格式,但想法保持不变),它将检查更新并应用它们(如果存在)。

我的意思是我希望我的团队能够运行vagrant_launch.sh这样做的事情

if box is out of date:
    update the box
vagrant up

这可能是if box is out of date:部分吗?

1 个答案:

答案 0 :(得分:1)

您可以在特定的Vagrantfile上运行vagrant box outdated以检查此特定内容是否已过时。

您还可以运行vagrant box outdated --global来检查已安装的所有方框,例如

fhenri@machine:~$ vagrant box outdated --global
* 'windows_ie' wasn't added from a catalog, no version information
* 'ubuntu/trusty64' is outdated! Current: 20151117.0.0. Latest: 20151201.0.0
* 'ubuntu-12.04' wasn't added from a catalog, no version information
* 'puphpet/centos65-x64' is outdated! Current: 2.0. Latest: 20151130
* 'hashicorp/boot2docker' (v1.7.8) is up to date
* 'centos65' wasn't added from a catalog, no version information
* 'boxcutter/ubuntu1504' is outdated! Current: 2.0.9. Latest: 2.0.10
* 'aribabox' wasn't added from a catalog, no version information

您可以从Vagrant来源查看,但基本上,如果该框具有元数据信息,它将从地图集(盒子仓库)进行检查,并从具有此名称的最新框中获取元数据并比较2个元数据。