Vagrant: Oracle Linux 8 VM
Published: 2021-12-12 21:01:00

<!-- wp:paragraph -->
<p>This is the first in <a href="https://alliterationapplications.com/tag/gitlab-devops/" data-type="post_tag" data-id="17">a series setting up a basic DevOps pipeline</a> through local virtual machines, GitLab, a dev server, a staging server, and a production server. This first post will look at the local VM setup. The next step will move on to using this local VM in connection with GitLab for version control and CI/CD.</p>
<!-- /wp:paragraph -->

<!-- wp:more -->
<!--more-->
<!-- /wp:more -->

<!-- wp:heading -->
<h2>Oracle Linux 8 LAMP stack</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The VM will be using <a data-type="URL" data-id="https://www.vagrantup.com/" href="https://www.vagrantup.com/">Vagrant </a>and <a data-type="URL" data-id="https://www.virtualbox.org/" href="https://www.virtualbox.org/">Oracle VirtualBox</a>. Every user will need to install both, as well as the VirtualBox extensions, for this to work.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The configuration for the Vagrant box can be found on <a data-type="URL" data-id="https://github.com/ryan-l-robinson" href="https://github.com/ryan-l-robinson">my GitHub</a>. For the sake of this demonstration, it is a fairly simple Oracle Linux 8, using a build in the Vagrant repository.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The first script, provision.sh, sets up the basic VM with a LAMP stack:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li>Apache</li><li>MySQL</li><li>PHP 8.0</li><li>Several PHP extensions</li><li><a data-type="URL" data-id="https://getcomposer.org/" href="https://getcomposer.org/">Composer</a></li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>That's a nice generic LAMP stack. If you want an Oracle Linux 8 LAMP stack for some other purpose, you can stop there.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>Drupal 9 local dev</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>In my case, the purpose of this vagrant box is for the first stage of development on a Drupal 9 website. So I'm going to go a few steps further to get it ready for the specific Drupal 9 project. That includes:</p>
<!-- /wp:paragraph -->

<!-- wp:list -->
<ul><li><span style="color: var(--nv-text-color); font-family: Graphik,-apple-system,BlinkMacSystemFont,Segoe UI,var(--nv-fallback-ff); letter-spacing: 0px; background-color: var(--nv-site-bg);">Sync the user's SSH key from their computer's folder to </span>the vagrant user's home folder, so that <a href="https://alliterationapplications.com/all/websites/my-web-development-workflow/" data-type="post" data-id="732">it can be used to connect to GitLab</a></li><li>Configures git including pulling the latest version of the code from the GitLab</li><li>Imports a MySQL database if one is provided</li><li>Self-signed keys so that https browsing will be possible</li></ul>
<!-- /wp:list -->

<!-- wp:paragraph -->
<p>I may write up specific details of some of these later, but <a href="https://github.com/ryan-l-robinson/Oracle-Linux-LAMP" data-type="URL" data-id="https://github.com/ryan-l-robinson/Oracle-Linux-LAMP">the bottom line is the code in GitHub.</a> This part is in the provision script d9.sh, which also references a separate script specifically for the database import called importdb.sh.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2>The user experience</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The idea is that at the end of this, the person setting up their machine has very few steps:</p>
<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} -->
<ol><li><code>Git clone</code> the repo for building the virtual machine on their PC</li><li>Put a copy of the database to import, if available, in the specified location</li><li>Put a copy of the SSH key into the specified location</li><li>Run <code>vagrant up</code> to build the virtual machine</li><li>SSH into the VM and then run the separate script for the Drupal 9 components</li><li>Optionally add the dev URL to the hosts file of their computer so that it is browsable at the URL and not just at localhost</li></ol>
<!-- /wp:list -->