Posted  by  admin

Macos Vagrant Box

Vagrant provides the framework and configuration format to create and manage complete portable development environments. These development environments can live on your computer or in the cloud, and are portable between Windows, macOS, and Linux. Vagrant ships out of the box with support for VirtualBox and HyperV only. What is Parallels Provider? Boxes are the package format for Vagrant environments. A box can be used by anyone on any platform that Vagrant supports to bring up an identical working environment. The vagrant box utility provides all the functionality for managing boxes. You can read the documentation on the vagrant box command for more information. PhpStorm makes it possible to execute the init procedure on a project root. After performing init on a project root, the Vagrant configuration file named Vagrantfile is created there. This file can be used for creating a remote interpreter. Initializing a virtual box. From the main menu, choose Tools Vagrant Init in Project Root. From the Select Vagrant Folder list, select. Vagrant 1.8 changed SMB mounting to use the more secure credential file mechanism. However, many operating systems ship with an outdated filesystem type for SMB out of the box which does not support this. The above workaround reverts Vagrant to the insecure before, but causes it work.

  1. Vagrant Public Boxes
  2. Vagrant Box Add
Macos Vagrant Box

A while ago, the chaps over at the Vagrant project have recently released a plugin to let Vagrant work with VMWare Fusion - this means we can finally use Vagrant to provision OS X VMs.

Why is this a good thing? Do you NetBoot VMWare to test your builds? Or maybe you still have that test Mac on your desk to test your builds. Either way, it’s going to be several minutes to restore an image, even if you’re thin imaging. With the VM already on your machine, you’re ready to go in seconds. Another bonus is that Vagrant isn’t only limited to OS X virtual machines - for example, I have a Vagrant configuration that spins up an Ubuntu box configured as a Munki server, with a copy of my repository on an external drive. This allows me to test deployments from anywhere, with everything local to my Mac (have you ever tried testing a Final Cut Studio package from home? 48GB takes a while to download.). I’ll go into more detail on this setup in a future post, but for now here’s how to get a Mac base box into Vagrant.

##Pre-requisites

  • Vagrant (this was written using Vagrant 1.2.7)
  • Packer (I’m using Packer 0.3.1)
  • Git (Install the Command Line Tools from within Xcode’s preferences if you don’t have it).

##Get set up with Packer

Before we install Packer, you’re going to need to download it. No, really, you need it.

Assuming you’ve downloaded it to ~/Downloads, extract the zip file so you will be left with something like this: ~/Downloads/0.3.1_darwin_amd. Everything prefaced with a $ should be entered in your terminal.

You now have a choice: you can refer to the packer binary by it’s full path every time (/usr/local/packer/packer), or you can modify your path. The next step is entirely optional, but I highly recommend it. You need to edit ~/.profile.

And add this line to the file, then save it (CTRL-O then CTRL-X):

And then quit and re-open Terminal.app.

Templates

Packer uses template files to define how it should build the VM for you. Fortunately, Tim Sutton has created a template file that can be used with Packer.

There are a couple of prep steps we need to do before we can instruct Packer to make our box. First off it’s going to need installation media. There is a script that will prepare the Install OS X Mountain Lion.app so it can be used with Packer.

You’ll see some activity in your terminal, and then you’ll be given the filename of your installation DMG and the checksum. You’ll need these in the next step.

Open up packer/template.json in your favourite editor. Paste in the checksum you were given in the last step (yours will probably be different from mine), and specify the path to your installation DMG (obviously use the path to your home directory, not mine!). You can also edit the size of the disk, the memory etc in this file.

Vagrant box add

Prepare the build!

You’re ready to go. This next step will take AGES so go and make a cup of coffee (or tea), as this is going to install OS X, run through the scripts to install the bits Vagrant needs (like Puppet), then make a Vagrant base box.

After you hit return, VMware will open up and OS X will start installing. Once everything is done, and Packer tells you it’s done in your terminal window, you just need to add it to Vagrant and then you’re ready to use it.

##Adding the VM to Vagrant

Macos Vagrant Box

Using the VM in Vagrant

We’re going to make a quick Vagrant configuration using your newly built box.

You’re probaly going to want a GUI when it boots, so open up ~/Desktop/osx_test/Vagrantfile in your text editor of choice and find the next section.

And change it to read

Unfortunately there isn’t any support for OS X in the official Vagrant release (yet), but good old Tim Sutton has sorted that out for us. We’re going to clone his repository, switch to the branch with his changes and copy the needed files into the main Vagrant installation. Hopefully his changes will be merged into a future of Vagrant, but for now:

We’re ready to boot the thing now - make it so, number one.

You should see VMWare Fusion open if it’s not already running and your VM boot after a little while.

What’s next?

You can configure this box with a script, or using Puppet or Chef (can you guess which I’d do?)?

In this tutorial you will be able to install GitLab Community Edition locally on your mac using a vagrant box. This tutorial has been tested with macOS 10.15 and at the time of writing this tutorial, the latest version of GitLab CE is 12.9.3 and the latest version of Ubuntu is 18.04 (bionic64).

Vagrant

Required

First you must make sure all the following are installed.

  1. Vagrant - download vagrantup.com
  2. Virtual Box - download virtualbox.org
  3. Github Desktop (Optional for section 8) - download desktop.github.com

NOTE: Ruby versions 2.0 and above are included by default in macOS releases since at least El Capitan (10.11).

You should already have ruby installed so lets check this first.

This should output something like.

1. Create the vagrant file

At first in the terminal make the directory that will be used for the GitLab CE installation and set it as default, so for this example 'gitlab-local'.

Then create a vagrant file.

Now open this file.

And replace the content with the following - you may need to change the forwarded_port and private_network to your own settings.

Now startup the vagrant box, this will initially take a while to install all the required files such as Gitlab CE.

Change the host file to recognise http://gitlab.local in your browser by opening the following which should also ask for your password.

Then add the following line at the bottom and save it.

2. Change the default hosting url (gitlab.example.com) for Gitlab CE

Access the Ubuntu terminal of the virtual box.

Now in the same terminal window edit the following file.

And find and replace.

With.

Then enter the following for the change to take effect.

3. Login to GitLab CE dashboard and change your user details

Vagrant

Open your browser with url http://gitlab.local. The first time around it will ask you to change your password.

Once done it will redirect you to the login page. By default the username is root so just enter this and your new password.

Now you should have access to the Gitlab CE Dashboard.

4. Edit the user account

First thing you should do is change your user details, so choose Settings and change your 'Email' and 'Full name' then press the 'Update profile settings' button.

You will receive an email just to confirm that it's exists. If the external_url has worked correctly the link in the email will work fine.

And then edit your username by selecting Account.

5. Create new repo

Create a new project so for this example I have used first-project.

You will be asked to first generate a SSH key.

6. Generate a new SSH key

Open a new terminal window and enter the following.

Then enter the filename you want the key to be named, just press return if you want to keep the default generated name but I would suggest using a custom name and remember to include the full directory in the filename like below.

Now just press enter twice to keep the passphrase empty.

Open the public key with your naming above.

You will have a line of random code begining with 'ssh-rsa' so copy this for use with GitLab.

Go back to the GitLab CE dashboard and press the Add SSH Key and paste the public key then press Add key.

You should get an email to confirm this.

7. Access the new repo via the terminal (or with the 'GitHub Desktop app' see section 8)

First open the following file and link your ip/url to your key.

And add the following.

So now you can clone the repo by entering this in the terminal.

It will initially ask you the below, so just enter 'yes'.

This should be working fine.

Vagrant Public Boxes

8. Access the new repo with the GitHub Desktop app

With the Github Desktop application things work a little different regarding accessing your repos. So lets start by selecting Settings then Access Tokens on the left navigation.

At first enter a name - so for this example 'First Project' and select the api checkbox. Then press the 'Create personal access token' button.

The page should refresh and generate a code under Your New Personal Access Token. Make sure to get a copy of this code because we will need to use this in the Github Desktop application.

Now select the 'Your Gitlab Name / first-project' repo.

On the following page choose the Clone dropdown button and highlight either the http or https that appears so for example.

Now launch the GitHub Desktop app and choose 'Clone a Repository from the Internet...'.

Input the repo url and the destination folder.

  • Repository URL: http://gitlab.local/your-gitlab-name/first-project.git

  • Local Path: /Users/[username]/gitlab-local-repos/first-project

Now the first time doing this you will be asked for the Authentication Login so add your username (for this example 'Your Gitlab Name') which you used to access the GitLab dashboard and the password which should be the generated 'Personal Access Token'.

Now you should get the cloning progress bar and it will have synced the repo of your local GitLab CE.

Vagrant Box Add

I hope this has been helpful.