Cloud customer?
Start for Free >
Upgrade in MyJFrog >
What's New in Cloud >

Search





Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

On top of general support for advanced artifact management, Artifactory support for

Newtablink
TextVagrant
URLhttp://docs.vagrantup.com/v2/boxes.html
provides:

  1. Distribution and sharing of Vagrant boxes within your organization.
  2. Calculation of Metadata for Vagrant boxes hosted in Artifactory's local repositories
  3. Extensive security features that give you fine-grained access control over boxes.
  4. Support for flexible repository layouts that allow you to organize your boxes and assign access privileges according to projects or development teams.
  5. Smart searches for boxes.

Configuration

Local Repositories

To create a local Vagrant repository to host your Vagrant boxes, from the Administration module | Repository Management | Repositories | Local and create a new Local Repository and set Vagrant as the Package Type.

Panel
titlePage Contents

Table of Contents
maxLevel4
minLevel2
 



Deploying Vagrant Boxes

Deploying a package using the UI

To deploy a Vagrant box to Artifactory, in the Application module, under Artifactory | Artifacts select the repository to which you want to deploy your Vagrant box and click Deploy.

The Deploy dialog is displayed with your selected repository as the Target Repository and a default Target path. 

You can add properties you wish to attach to your box as parameters to the target path.

For example, to upload the box precise64-virtualbox-1.0.0.box, and specify that its name is precise64, with a provider of virtualbox and the version is 1.0.0, you would enter:

Code Block
languagetext
titleSpecifying the Target Path
/precise64-virtualbox-1.0.0.box;box_name=precise64;box_provider=virtualbox;box_version=1.0.0

Set Me Up

You can also select your repository and click Set Me Up to view the cURL command you can use to upload your box.

Note
titleBe careful with spaces

Make sure you don't enter any superfluous spaces in the Target Path specification.


Once you have deployed your Vagrant box, and Artifactory has recalculated the repository index, your repository should be organized as displayed below:


Deploying a package using Matrix Parameters

You can also deploy Vagrant boxes to Artifactory with an explicit URL using Matrix Parameters.

The URL is built similarly to the Target Path format as follows:

Code Block
titleDeploying a package using Matrix Parameters
PUT "http://{Artifactory URL}/{vagrantRepoKey}/{vagrantBoxName.box};box_name={name};box_provider={provider};box_version={version}" 

For example, to upload the box precise64-virtualbox-1.0.0.box, and specify that it's name is precise64, with a provider of virtualbox and the version is 1.0.0, you would enter:

Code Block
languagetext
titleExample
PUT "http://localhost:8080/artifactory/vagrant-local/precise64-virtualbox-1.0.0.box;box_name=precise64;box_provider=virtualbox;box_version=1.0.0"

Setting the Target Path

The Target Path can be anywhere in the repository, but it has to contain the 3 mandatory matrix parameters: box_name, box_provider and box_version and the file name must end with .box. The format is as follows:

Code Block
languagetext
titleTarget Path Format
PUT "http://{Artifactory URL}/{vagrantRepoKey}/{path/to/vagrantBoxName.box};box_name=[name];box_provider=[provider];box_version=[version]"
name
The value to assign to the box_name property used to specify the Vagrant box name.
provider
The value to assign to the box_provider property used to specify the Vagrant box
Newtablink
Textprovider
URLhttp://docs.vagrantup.com/v2/providers/basic_usage.html
(virtualbox/lxc or others).
version
The value to assign to the box_version property used to specify the Vagrant box version (must comply with
Newtablink
TextVagrant's versioning schema
URLhttp://docs.vagrantup.com/v2/boxes/versioning.html
)

Provisioning Vagrant Boxes

Vagrant boxes are available through the following URL:

Code Block
languagetext
titleVagrant box URL
vagrant box add "http://{Artifactory URL}/api/vagrant/{vagrantRepoKey}/{boxName}"


Note
titleSpecifying the path to the box

With Vagrant client commands, make sure you don't specify the path to a box in the command. The path should be specified using properties.

For example, to provision a Vagrant box called precise64 from a repository called vagrant-local, you would construct it's name in the following manner:

Code Block
languagetext
titleProvisioning a Vagrant box
vagrant box add "http://localhost:8080/artifactory/api/vagrant/vagrant-local/precise64"

You can select the repository from which you want to provision your box, and click Set Me Up to get the specific URL for the selected repository.

You can also, optionally, pass parameters to specify a specific box version or provider. For example:

Code Block
languagetext
titleProvisioning a Vagrant box by version
vagrant box add "http://localhost:8080/artifactory/api/vagrant/vagrant-local/precise64 --provider virtualbox --box-version 1.0.0"

In addition, boxes can be provisioned using properties; this is useful when you want to download the latest box tagged by a specific property.
The properties query parameter value should comply with Using Properties in Deployment and Resolution

Examples:
Code Block
languagetext
titleProvisioning a Vagrant box by version
vagrant box add "http://localhost:8080/artifactory/api/vagrant/vagrant-local/precise64?properties=box_version%2B=3.0.0"

Note the '%2B' 

Newtablink
Textencoding
URLhttp://www.w3schools.com/tags/ref_urlencode.asp
 on the command for the '+' symbol (which is for Mandatory properties: key+=value)  

The following example downloads a box with box_name=trusty64, box_version=3.0.0 from path="folder".

It uses an optional "path" property ( in addition to the mandatory properties) to specify the path where the box is stored in Artifactory. We will use this property for resolution of the box.

Code Block
vagrant box add "http://localhost:8080/artifactory/api/vagrant/vagrant-local/trusty64?properties=box_version%2B=3.0.0;path%2B=folder"

Note the format for resolution of multiple properties: key1+=value1;key2+=value2....

Specifying box resolution path as a propertyImage Modified

Authenticated Access to Servers

If you need to access a secured Artifactory server that requires a username and password, you need to specify 2 environment variables:

  1. ATLAS_TOKEN 

    1. This token is a 

      Newtablink
      TextBase64
      URLhttp://www.base64encode.org/
       encoded string of the user credentials (formatted username:password). 

    2. It can be generated by any user from Artifactory with the following command:

      Code Block
      $curl -uadmin:password "http://localhost:8080/artifactory/api/vagrant/auth"
      YWRtaW46QVAzWGhzWmlDU29NVmtaQ2dCZEY3XXXXXXXX
    3. It is not related to the user's access token, API key or encrypted password

    4. It is only used for downloading Vagrant boxes from private repositories in Artifactory

    5. The token will change if the user's password changes

    6. For more details on the ATLAS_TOKEN, please refer to the 

      Newtablink
      TextVagrant documentation
      URLhttps://www.vagrantup.com/docs/vagrant-cloud/users/authentication.html
      .

  2. VAGRANT_SERVER_URL - The base URL for the Artifactory server.
Code Block
titleSetting ATLAS_TOKEN and VAGRANT_SERVER_URL
export ATLAS_TOKEN={token}
export VAGRANT_SERVER_URL=http://{Artifactory URL}/api/vagrant/{vagrantRepoKey}
For example:
export ATLAS_TOKEN=YWRtaW46QVAzWGhzWmlDU29NVmtaQ2dCZEY3XXXXXXXX
export VAGRANT_SERVER_URL=http://localhost:8081/api/vagrant/vagrant-local
Note
titleBoth environment variables are required

When using Artifactory with authenticated access (i.e. anonymous access is disabled), both of these environment variables are required. If either of them is not set, the Vagrant client will not be able to access Artifactory and a 401 error message will be generated.



Watch the Screencast

HTML
<iframe width="560" height="315" src="https://www.youtube.com/embed/7Fa0oO5suww" frameborder="0" allowfullscreen></iframe>



Copyright © 2021 JFrog Ltd.