Skytap provider for Vagrant quick start

This quick start guide demonstrates some of the basic functionality of Skytap and the Skytap provider for Vagrant.

First, we’ll install Vagrant and the Skytap provider for Vagrant on a Skytap VM. Then we’ll use the provider to quickly create Skytap environments from a Skytap template.

You can also install the Skytap provider for Vagrant on your local machine if you’re an established Skytap customer with a VPN connection between your local network and Skytap.

Contents

Step 1: Install Vagrant and the Skytap provider on a Skytap VM

First, we’ll create a VM from a Skytap Ubuntu 16.04 public template. Then, we’ll install Ruby, Vagrant, and the Vagrant provider on it.

  1. In your Skytap account, create an environment from the Ubuntu 16.04 Desktop public template. For detailed instructions, see Creating an environment from a template.

    For best performance, use a template in the region closest to you.

  2. In the new environment, edit the network settings to enable NAT and make the network visible to other networks in Skytap. For detailed instructions, see Editing an automatic network.
  3. Click run Run to start the Ubuntu 16.04 Desktop VM.
  4. Click the VM thumbnail to begin interacting with the VM in your browser. VM Desktop Thumbnail

  5. Sign into Ubuntu as the skytap user. The password is stored in the credentials (Credentials) module in the top toolbar.

    HTML5 Client Credentials

  6. In a terminal window, install Ruby version 2.0 or higher on the VM. For example, use the following command.

     sudo apt install ruby-full
    
  7. Install the gdebi package installer as an alternative to the native software installer on this VM. This step is only required due a bug in the 16.04 Ubuntu operating system.

     sudo apt install gdebi
    
  8. Download the Vagrant 1.8.1 Debian 64-bit installation package on the VM (for example, vagrant_1.8.1_x86_64.deb). Use gdebi to install the package.

    Verify the installation with the command vagrant --version.

  9. Use the following command to download and install the Skytap provider on the VM.

     vagrant plugin install vagrant-skytap
    

    Verify the installation with the command vagrant plugin list. The Skytap provider should be listed.

Step 2: Prepare a Skytap template to use with Vagrant

Next, we’ll create a Skytap template, with some Vagrant-specific configuration changes. These changes allow the Vagrant provider to connect to and use SSH with VMs created from this template.

Perform the following steps from the VM you created in Step 1.

  1. Use the VM browser to sign in to your Skytap account.
  2. Create an environment in Skytap (for example, create an environment from the Ubuntu 16.04 Server public template). The environment must be in the same region as the environment you created in Step 1: Install the Skytap provider for Vagrant on a Skytap VM.
  3. Modify the network settings in the environment to enable NAT and make the network visible to other networks in Skytap. For detailed instructions, see Editing an automatic network.
  4. Save the VM login user name and password in the VM credentials. If you created a VM from a public template, the VM should already have saved credentials. For detailed instructions, see Storing VM credentials.
  5. Enable SSH for a user account in the VM. To do this:
    1. Click run Run to start the VM.
    2. Click the VM thumbnail to begin interacting with the VM in your browser.
    3. Sign into the VM. If you’re using the Ubuntu 16.04 Server VM, login as the skytap user; the password is saved in the VM credentials.
    4. Open a terminal window and type sudo visudo. Re-enter the password.
    5. Use the arrow keys to navigate to the end of the file. Add the following line to the end of the file:

       skytap ALL=(ALL) NOPASSWD:ALL
      

      If you’re using a different login name, replace skytap with the correct login name

    6. Press Ctrl+X to exit, and type Y at the prompt to save the changes.
    7. Shut down the VM.
  • Save the environment as a template.

Step 3: Generate a Vagrantfile for the Skytap template

In this step, we’ll create a Vagrantfile that includes information about Skytap template we created in Step 2 (above).

Perform the following steps from the VM you created in Step 1.

  1. Use the VM browser to login into your Skytap account and navigate to the template you created in Step 2.
  2. In the address bar of the browser, add /vagrantfile?include_api_credentials=true to the template page URL and click Enter.

    For example, https://cloud.skytap.com/templates/738489/vagrantfile?include_api_credentials=true. This displays a pre-made Vagrantfile for the template that includes your Skytap user name and API token; it should look like the sample below.

     # This Vagrantfile was generated from:
     # "Vagrant Box - Ubuntu 12.04.1 LTS Server (64-bit) Linux"
     # https://cloud.skytap.com/templates/738489
    
     Vagrant.configure(2) do |config|
     # The "skytap/empty" box contains minimal metadata. The source VMs
         # are specified below using the vm_url setting.
         config.vm.box = "skytap/empty"
    
         # Credentials for the Skytap REST API. If you plan to check this
         # Vagrantfile into source control, consider omitting this block,
         # and setting the environment variables VAGRANT_SKYTAP_USERNAME
         # and VAGRANT_SKYTAP_API_TOKEN instead.
         config.vm.provider :skytap do |skytap|
             skytap.username = "<your username>"
             skytap.api_token = "<your API token>"
         end
    
         config.vm.define :vm1 do |vm1|
             vm1.vm.provider :skytap do |skytap|
             # Source VM: "Vagrant Box - Ubuntu 12.04 LTS Server (64-bit)"
             skytap.vm_url = "https://cloud.skytap.com/vms/8350530"
             end
         end
     end
    

    You can add /vagrantfile to any Skytap environment or template URL to generate a pre-made Vagrantfile from that resource.

    ?include_api_credentials=true is an optional URL parameter that automatically adds your user name and API token to the generated Vagrantfile. If you choose not to use the URL parameter, add your Skytap user name and password to the Vagrantfile or use environment variables (VAGRANT_SKYTAP_USERNAME and VAGRANT_SKYTAP_API_TOKEN).

  3. Save the Vagrantfile text from the browser into a new file named Vagrantfile (no file extension) on the VM.
  4. Create a directory named skytap-vp and move the Vagrantfile to it.

Step 4: Use Vagrant to create a Skytap environment from the Vagrantfile

In this last step, we’ll create a Skytap environment from the Vagrantfile.

  1. From the command line, navigate to the skytap-vp directory (the directory that contains the Vagrantfile). For example:

     cd skytap-vp
    
  2. Use the following command to create the VM:

     vagrant up
    
  3. At the Vagrant prompt, select the SSH credentials you added to the VM in Step 2 (Step 2: Prepare a Skytap template to use with Vagrant).

     ==> vm1: New Skytap environment created: https://cloud.skytap.com/configurations/12345678
     ==> vm1: Using only available connection option: Create and use tunnel to host network: Default Network
     How do you want to choose SSH credentials for machine 'vm1'?
     Note that credentials retrieved from the Skytap VM will be stored in cleartext on your local filesystem.
    
     1. Use VM credentials stored in Skytap: root/ChangeMe!
     2. Use VM credentials stored in Skytap: skytap/ChangeMe!
     3. Don't specify credentials: Use standard 'vagrant' login with insecure keypair
    

    Vagrant proceeds with the VM setup:

     Bringing machine 'vm1' up with 'skytap' provider...
     ==> vm1: Starting VMs ...
     ==> vm1: Waiting for machine to boot. This may take a few minutes...
     vm1: SSH address: 10.0.4.1:22
     vm1: SSH username: skytap
     vm1: SSH auth method: private key
     vm1: Warning: Host unreachable. Retrying...
     vm1: Warning: Host unreachable. Retrying...
     vm1: Warning: Connection refused. Retrying...
     vm1:
     vm1: Vagrant insecure key detected. Vagrant will automatically replace
     vm1: this with a newly generated keypair for better security.
     vm1:
     vm1: Inserting generated public key within guest...
     vm1: Removing insecure key from the guest if it's present...
     vm1: Key inserted! Disconnecting and reconnecting using new SSH key...
     ==> vm1: Machine booted and ready!
     ==> vm1: Clearing any previously set forwarded ports...
     ==> vm1: Forwarding ports...
     ==> vm1: Rsyncing folder: /home/skytap/Desktop/skytap-vp/ => /vagrant
    
  4. Verify that Vagrant has created and started the VM by typing the command:

     vagrant status vm1
    
  5. SSH into the VM by typing the command:

     vagrant ssh
    

Next steps

After you’ve created a working environment with Vagrant: