<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Garvin</title>
    <description>The latest articles on DEV Community by Garvin (@garvinc).</description>
    <link>https://dev.to/garvinc</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F128720%2F6165d74c-2070-4c8b-b73f-6d457635498e.jpeg</url>
      <title>DEV Community: Garvin</title>
      <link>https://dev.to/garvinc</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/garvinc"/>
    <language>en</language>
    <item>
      <title>Why don't websites allow users to create their own security questions?</title>
      <dc:creator>Garvin</dc:creator>
      <pubDate>Thu, 11 Apr 2019 14:08:30 +0000</pubDate>
      <link>https://dev.to/garvinc/why-don-t-websites-allow-users-to-create-their-own-security-questions-7jn</link>
      <guid>https://dev.to/garvinc/why-don-t-websites-allow-users-to-create-their-own-security-questions-7jn</guid>
      <description>&lt;p&gt;For those who are part of a team responsible for security on a web application, is there a reason why most sites don't allow users to choose their own challenge/security questions?&lt;/p&gt;

</description>
      <category>security</category>
      <category>discuss</category>
      <category>question</category>
    </item>
    <item>
      <title>From ISO to VHD in Azure using DevOps</title>
      <dc:creator>Garvin</dc:creator>
      <pubDate>Fri, 22 Mar 2019 18:08:41 +0000</pubDate>
      <link>https://dev.to/garvinc/from-iso-to-vhd-in-azure-using-devops-4241</link>
      <guid>https://dev.to/garvinc/from-iso-to-vhd-in-azure-using-devops-4241</guid>
      <description>&lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;br&gt;
The repo has been updated to use Github Actions. The readme has been updated to reflect this. &lt;/p&gt;

&lt;p&gt;Have you ever had to manually install an operating system from scratch to create base images for use in the cloud? Are you required to periodically rebuild these base images because of patches and updates? Are you working on a packer plugin? This blog post introduces an end to end DevOps pipeline for creating base images from OS install disks in ISO format. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How will this work?&lt;/strong&gt;&lt;br&gt;
This process relies on the &lt;a href="https://azure.microsoft.com/en-us/blog/nested-virtualization-in-azure/" rel="noopener noreferrer"&gt;nested virtualization&lt;/a&gt; feature available in Azure. First, A builder VM capable of running nested VMs will be created. Then within the builder VM, packer will be used to create the base images. Once the image creation process is complete, images are copied from the builder VM to Azure storage. From there, these images can be used to create VMs or used as source images in a separate pipeline based on the packer &lt;a href="https://www.packer.io/docs/builders/azure.html" rel="noopener noreferrer"&gt;Azure Builder&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6o1v0165gxmkqyn9t3z3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6o1v0165gxmkqyn9t3z3.png" alt="ISO to VHD in Azure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Requirements&lt;/strong&gt;&lt;br&gt;
There are a few different tools required to fully automate this process. If you are not familiar with any of them it would help to read up on them before proceeding. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a free &lt;a href="https://azure.microsoft.com/en-us/services/devops/" rel="noopener noreferrer"&gt;Azure DevOps account&lt;/a&gt; if you don't already have one. Then follow the documentation to create a &lt;a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/get-started-designer?view=azure-devops&amp;amp;tabs=new-nav" rel="noopener noreferrer"&gt;basic pipeline&lt;/a&gt;. &lt;/li&gt;
&lt;li&gt;Signup for an &lt;a href="https://azure.microsoft.com/en-us/offers/ms-azr-0044p/" rel="noopener noreferrer"&gt;Azure free trial&lt;/a&gt; if you don't already have access to an Azure subscription. &lt;/li&gt;
&lt;li&gt;This process relies on packer to build images so please visit the &lt;a href="https://www.packer.io/intro" rel="noopener noreferrer"&gt;getting started&lt;/a&gt; page to familiarize yourself with the tool. Specifically, the &lt;a href="https://www.packer.io/docs/builders/qemu.html" rel="noopener noreferrer"&gt;Qemu&lt;/a&gt; based image builder. &lt;/li&gt;
&lt;li&gt;The image builder will be an Ubuntu VM configured using &lt;a href="https://docs.microsoft.com/en-us/azure/virtual-machines/linux/using-cloud-init" rel="noopener noreferrer"&gt;cloud init&lt;/a&gt;. If you are not familiar with cloud init, please take some time to &lt;a href="https://cloudinit.readthedocs.io/en/latest/" rel="noopener noreferrer"&gt;learn&lt;/a&gt; about it. &lt;/li&gt;
&lt;li&gt;The packer created nested VMs will use &lt;a href="https://docs.centos.org/en-US/centos/install-guide/Kickstart2/" rel="noopener noreferrer"&gt;kickstart&lt;/a&gt; files to automatically install the OS. In this case, I have chosen &lt;a href="https://www.centos.org/download/" rel="noopener noreferrer"&gt;Centos&lt;/a&gt; as the base OS. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Repository&lt;/strong&gt;&lt;br&gt;
The source code repository for this pipeline will contain a set of bash scripts and the config files required for configuring the builder and nested VMs. Please download them from my &lt;a href="https://github.com/garvincasimir/Azure-ISO-To-VHD" rel="noopener noreferrer"&gt;Github&lt;/a&gt; account and upload to your Azure DevOps repository. You also have the option of using a &lt;a href="https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/github?view=azure-devops" rel="noopener noreferrer"&gt;Github repository&lt;/a&gt; as the source of a DevOps pipeline.&lt;/p&gt;

&lt;p&gt;At this point you should have the following files and directory layout in your repository&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1xuywpakul21w3i5swc3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1xuywpakul21w3i5swc3.png" alt="ISO to VHD In Azure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Builder VM&lt;/strong&gt;&lt;br&gt;
The &lt;em&gt;cloud-init.yaml&lt;/em&gt; is used to configure the Ubuntu Builder VM. This vm will be created using the latest Ubuntu image in the &lt;a href="https://azuremarketplace.microsoft.com/en-au/marketplace/apps/Canonical.UbuntuServer" rel="noopener noreferrer"&gt;Azure Marketplace&lt;/a&gt;. The cloud init file will also contain a base64 representation of the bash scripts required to install packer, build dependencies and config files.  Keep in mind that this file is only used as a template. The &lt;em&gt;gen-init.sh&lt;/em&gt; script replaces all file paths in &lt;em&gt;cloud-init.yaml&lt;/em&gt; with the base64 representation of the file and saves the result to &lt;em&gt;cloud-init-gen.yaml&lt;/em&gt;. Please add this file to your &lt;em&gt;.gitignore&lt;/em&gt; as it should be generated during the build process. &lt;/p&gt;

&lt;p&gt;The &lt;em&gt;packer-build.sh&lt;/em&gt; script will be used to build the image. It will be run from Azure DevOps using the Azure CLI &lt;a href="https://docs.microsoft.com/en-us/cli/azure/vm/run-command?view=azure-cli-latest#az-vm-run-command-invoke" rel="noopener noreferrer"&gt;run-command&lt;/a&gt; feature. This feature allows you to run a command within an Azure vm without an SSH connection. Learn more about run-command &lt;a href="https://docs.microsoft.com/en-us/azure/virtual-machines/linux/run-command" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Pipeline&lt;/strong&gt;&lt;br&gt;
The build pipeline consists of 4 agent jobs. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;em&gt;Setup&lt;/em&gt; job contains tasks responsible for creating the builder vm. &lt;/li&gt;
&lt;li&gt;The &lt;em&gt;Build&lt;/em&gt; job contains the tasks responsible for running packer. &lt;/li&gt;
&lt;li&gt;The &lt;em&gt;Upload&lt;/em&gt; job uploads the finished VHD to Azure storage. &lt;/li&gt;
&lt;li&gt;The optional &lt;em&gt;Test Create VM From VHD&lt;/em&gt; job creates a test vm from from the uploaded VHD. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is very important that each job is configured to depend on the preceding job. Otherwise Azure DevOps might run them out of order. Technically, these tasks can all run within a single agent job. However, they are separated to stay within the 30 minute run time allowed on hosted agents in the free tier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbul6ccsjzjzjs0k4bxuh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fbul6ccsjzjzjs0k4bxuh.png" alt="Pipeline Setup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please perform the following actions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-portal" rel="noopener noreferrer"&gt;create the storage account&lt;/a&gt; that will be used to upload the finished base images. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create the 4 agent jobs mentioned above. Be sure to configure each job to depend on the preceding job.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add the following variables to the build pipeline. Please include everything that isn't a system variable. &lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6s1ssm9qkpv80z7rkp15.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F6s1ssm9qkpv80z7rkp15.png" alt="pipeline variables"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The resource group name you select should not already exist. &lt;strong&gt;&lt;strong&gt;The script will delete the resource group if it exists&lt;/strong&gt;&lt;/strong&gt;. After the image is uploaded to storage, the resource group and all the resources in it are no longer needed. Deleting the resource group will delete the group and all resources in it. Please do not deploy any other resources to this group. Select a name that can be dedicated to this pipeline. The Azure connection used in the CLI tasks should have permissions to delete/create resource groups, managed images, storage SAS tokens and virtual machines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Deploy Builder VM&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a new Azure CLI task in the &lt;em&gt;Setup&lt;/em&gt; job and name it &lt;em&gt;Deploy Builder VM to Azure&lt;/em&gt;. &lt;/li&gt;
&lt;li&gt;Configure the task to run the &lt;em&gt;create-inception.sh&lt;/em&gt; script and include the previously created variables as parameters. &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Foymy0rjkney2f1316hks.png" alt="deploy builder vm"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Run Packer Build&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a new Azure CLI task in the &lt;em&gt;Build&lt;/em&gt; job and name it &lt;em&gt;Run Packer Build on Builder VM&lt;/em&gt;. &lt;/li&gt;
&lt;li&gt;Configure the task to execute the &lt;em&gt;run-packer-build.sh&lt;/em&gt; script and include the previously created variables as parameters. &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Flj1uo79py7iayogghgi4.png" alt="Run packer build"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;VHD upload&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a new Azure CLI task in the &lt;em&gt;Upload&lt;/em&gt; job and name it &lt;em&gt;Run Upload VHD&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Configure the task to execute the &lt;em&gt;run-upload-vhd.sh&lt;/em&gt; script and include the previously created variables as parameters. &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fsb8qrq69ul75nneke9b3.png" alt="Upload VHD"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Create a test VM&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a new Azure CLI task in the &lt;em&gt;Test Create VM From VHD&lt;/em&gt; job and name it &lt;em&gt;Create Test VM&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Configure the task to execute the &lt;em&gt;create-test-vm.sh&lt;/em&gt; script and include the previously created variables as parameters. &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1y9948lz1vtwe1g1k1xc.png" alt="Upload VHD"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Troubleshooting&lt;/strong&gt;&lt;br&gt;
If your image isn't being built for some reason I recommend using remote desktop to troubleshoot. The script configures the image builder vm to enable RDP access to allow frictionless troubleshooting. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The osx based RDP client from Microsoft seems to be the most responsive. &lt;/li&gt;
&lt;li&gt;From the builder VM desktop start a root based terminal and run the &lt;em&gt;/root/packer-buil.sh&lt;/em&gt; build script. &lt;/li&gt;
&lt;li&gt;Take note of the vnc connection information in the console output. e.g. vnc://127.0.0.1:5909&lt;/li&gt;
&lt;li&gt;Open the remote viewer and enter the VNC connection information&lt;/li&gt;
&lt;li&gt;You can now see and interact with the VM being built&lt;/li&gt;
&lt;li&gt;You an also run packer with the -debug flag so it will pause at each step while you manually interact with the nested vm&lt;/li&gt;
&lt;li&gt;Install &lt;a href="https://www.realvnc.com/en/connect/download/viewer/" rel="noopener noreferrer"&gt;Real VNC Viewer&lt;/a&gt; if the pre-installed viewer does not work correctly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br&gt;
If everything goes right you should have a virtual machine based on the custom VHD generated in your pipeline. When you are happy with the results, create an Azure CLI task responsible for deleting the resource group. I published the exported pipeline and all the scripts mentioned in this post to my &lt;a href="https://github.com/garvincasimir/Azure-ISO-To-VHD" rel="noopener noreferrer"&gt;github&lt;/a&gt; repository. Feel free to create issues and make contributions.&lt;/p&gt;

</description>
      <category>azure</category>
      <category>devops</category>
      <category>packer</category>
      <category>githubactions</category>
    </item>
  </channel>
</rss>
