In an earlier article, I explored running my Azure Pipelines builds on a custom build agent using a Windows VM in the AWS cloud. Today, I will attempt a similar thing, but this time using a Linux VM in the Oracle Cloud. Since much of the process is the same, this article will focus on the challenges that are different.
Creating a virtual machine
On the Oracle website, I chose to create a VM instance by clicking the shortcut from the Quick Actions on the Get Started page:
When I configured my instance, I used the default “Always Free Eligible” options wherever possible, including the Oracle Linux 7.9 image for the operating system (at the time of writing, Oracle Linux 7 is on the list of supported distributions for the Azure Pipelines agent).
Before clicking the Create button, I made sure to download the private key so that I can SSH into my instance later.
Once I clicked Create, the VM instance entered the “provisioning” status, and after a few moments turned to “running”. To connect to the instance:
- Copy the Public IP Address
- SSH into this address
If you’re connecting to your VM from a Windows machine (like me), remember that Windows has a built-in OpenSSH Server that you can install under the optional features.
The Oracle documentation has a guide explaining how to connect to a Linux instance from a Windows system using OpenSSH:
Connecting to an Instance
You can connect to a running instance by using a Secure Shell (SSH) or Remote Desktop connection. Most UNIX-style…
Take note of the security changes you are required to make to the properties of the private key file. The only permission listed should be “full control” for your account (which should be the owner of the file). If this isn’t correct, the connection will fail with a “permission denied” error:
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
Permissions for 'ssh-key-2021-01-09.key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Creating an agent pool in Azure DevOps
Refer to my earlier article for the steps to create an agent pool.
Deploying the Azure Pipelines agent
To make my new virtual machine a build agent, I needed to install the Azure Pipelines agent. The steps for doing so are detailed in this Microsoft article.
The first thing to do is to install git.
Note that simply running
sudo yum install git might not install the latest version of git. In my case, this installed 18.104.22.168, which is older than the minimum version required by Azure (2.0 at the time of writing). To get a newer version of git, I had to download the source and compile it myself. Here’s an article explaining the steps:
Git - Installing Git
Git is a member of Software Freedom Conservancy, which handles legal and financial needs for the project. Conservancy…
For reference, these are the commands I ended up using:
sudo wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gzsudo tar -zxf git-2.9.5.tar.gzcd git-2.9.5/sudo yum install autoconfsudo make configuresudo ./configure --prefix=/usrsudo make install
Next, the Microsoft guide says to download and configure the agent by logging into Azure DevOps from the target machine. Instead of doing this, I used my local Windows machine to download the necessary package and used SCP to copy this over to my remote machine in the Oracle cloud.
Below is an example of the command I used:
scp -i <private_key_file> .\vsts-agent-linux-x64-2.179.0.tar.gz <username>@<public-ip-address>:/home/opc example.txt
On the server, create a directory for the build agent, e.g.
mkdir myagent && cd myagent
Then extract the package into this directory, e.g.
tar zxvf ../vsts-agent-linux-x64-2.179.0.tar.gz
Next, execute the config.sh file, e.g.
Follow the on-screen prompts. This part is the same as for installing on Windows, so you can refer to my earlier article for guidance. There was one new question, however:
Enter Perform an unzip for tasks for each step. (press enter for N)
I pressed enter to accept the default. Unlike what happened with the Windows agent, I was not given the option to install the agent as a service. It’s possible to start the agent interactively using the following command:
This is enough to bring the agent online, which you can verify from DevOps. However, ending the SSH session will terminate the process, causing the agent to go offline again. To have the agent run in the background, run the following command to create the service file:
sudo ./svc.sh install
Then start it using this command:
sudo ./svc.sh start
These commands are listed in the Microsoft article, but thanks to this Bas Litjen blog post for pointing me in the right direction. The agent should now remain running even after you exit SSH.
That’s it for the Oracle/Linux-specific steps! The rest of it (i.e. registering the agent with DevOps and creating the pipeline YAML) is the same as in my earlier article.