Archive
How to Create Private Vagrant Cloud on Ubuntu 20.04

How to Create Private Vagrant Cloud on Ubuntu 20.04

2024-11-27 You may want to keep your Vagrant boxes in your own repository instead of the global cloud structure. This can often be quite important for internal

Related articles

VPN使用-西南石油大学网信中心 Manage your iCloud storage Best Cloud Storage for Linux in 2024 [Personal Storage Compared] Set Up MediaStreamer on Xbox Series X or Xbox One 始祖鸟与BEAMS合作系列3.0来了,Beta、Atom依然在列,将于12月2日发售!_冲锋衣_什么值得买 All Crafting Recipes in Aura Craft (340 Auras)

You may want to keep your Vagrant boxes in your own repository instead of the global cloud structure.

This can often be quite important for internal policies. Moreover, it makes sense to keep the vagrant boxes you think are in a place where only you can access them.

For this and similar reasons, I tried to create my secret vagrant repository and I saw that they explained the way to do it on the internet only for RHEL.

And you know… Some people (like me) are just not used to RHEL.

For these reasons, I wanted to explain how we can do this on Ubuntu.

How to Create Private Vagrant Cloud on Ubuntu 20.04

1. Apache Installation

As can be expected, we first start with installing the Apache.



sudo apt update
sudo apt install apache2


enter fullscreen mode
exit fullscreen mode

1.1. Creation of Necessary Directories

Before configuring Apache, we can create the necessary log directories.



 sudo mkdir /var / log / apache2 / vcloud 


enter fullscreen mode
exit fullscreen mode

1.2. Apache Configuration

To configure Apache simply, create a configuration file named vcloud.conf under /etc/apache2/sites-available/. Then add the following configurations into this file.



NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin zeki@acik.lab
    ServerName vcloud.acik.lab
    ServerAlias www.vcloud.acik.lab
    DocumentRoot /var/www/html
    <Directory "/var/www/html">
        Options All Indexes FollowSymLinks
        Order allow,deny
        Allow from all
  </Directory>
  ErrorLog /var/log/apache2/vcloud/error.log
  CustomLog /var/log/apache2/vcloud/access.log combined
</VirtualHost>


enter fullscreen mode
exit fullscreen mode

ServerName is very important in this configuration. In the future we will need to create a host record to access it.

1.3. Activate Configuration

To activate the configuration follow the steps.



 cd /etc / apache2 / site - available 
 sudo a2ensite vcloud.conf 


enter fullscreen mode
exit fullscreen mode

1.4 . create local host Record

create a record to reach the ServerName you give in the configuration .

To do this, add a line /etc/hosts file like this.



 10.20.30.78     vcloud.acik.lab 


enter fullscreen mode
exit fullscreen mode

If you try to access the repository from Windows, the address of this file should be something like C:\Windows\System32\Drivers\etc\hosts

1.5 . create directory for Vagrant Box

Create directories where we will put the Vagrant box. I choose the Pardus 21.0 distribution that I created myself.



sudo mkdir -p /var / www / html / vcloud / vagrant/pardus/21


enter fullscreen mode
exit fullscreen mode

2. Get Vagrant Box

That moment is come has come ! Let ‘s is download download the vagrant box . ( If you feel lose , you is experience should experience Pardus 21 with me . )

How to Create Private Vagrant Cloud on Ubuntu 20.04



sudo wget -O /var / www / html / vcloud / vagrant/pardus/21/pardus-21-0.1.0.box https://app.vagrantup.com/zeki/boxes/pardus21/versions/0.1.0/providers/virtualbox.box


enter fullscreen mode
exit fullscreen mode

2.1. Create Metadata File

After the download is complete , create a metadata file namepardus-21.json under /var / www / html / vcloud / vagrant/. Don’t mind the word metadata being so cool, it’s just a json file and fill its content as below.



{
  "name": "pardus/21",
  "description": "Pardus 21.0 XFCE",
  "versions": [
    {
      "version": "0.1.0",
      "providers": [
        {
          "name": "virtualbox",
          "url": "http://vcloud.acik.lab/vcloud/vagrant/pardus/21/pardus-21-0.1.0.box"
        }
      ]
    }
  ]
}


enter fullscreen mode
exit fullscreen mode

3. Restart Apache Services

After completing all these steps, we can activate Apache service.



sudo systemctl start apache2
sudo systemctl enable apache2


enter fullscreen mode
exit fullscreen mode

3.1 . accessibility Test

If all goes well you should see vagrant boxes at http://vcloud.acik.lab/vcloud/vagrant/.

4. Testing

create new vagrant directory and Vagrantfile to test . ( On the another server . )



mkdir pardus-21 && cd pardus-21
touch Vagrantfile


enter fullscreen mode
exit fullscreen mode

Insert the following lines into the Vagrantfile.



Vagrant.configure("2") do |config|
  config.vm.box = "pardus/21"
  config.vm.box_url = "http://vcloud.acik.lab/vcloud/vagrant/pardus-21.json"
  config.vm.synced_folder ".", "/vagrant", id: "vagrant-root", disabled: true
end


enter fullscreen mode
exit fullscreen mode

LET’S VAGRANT UP!



cd ~/pardus-21 
vagrant up


enter fullscreen mode
exit fullscreen mode

The output should look like this.

How to Create Private Vagrant Cloud on Ubuntu 20.04

Congratulations!! You now have a secret vagrant repository!

How to Create Private Vagrant Cloud on Ubuntu 20.04