Tumgik
swaginsondabs · 4 months
Text
How to Configure an Azure DevOps self hosted Pipeline Agent
Azure DevOps is a tool you can use, for free (with an existing business subscription) that allows you to do a lot of things:
Store code in git repos
Plan projects with a kanban style board
Automate deployments with pipelines
The third option is the most interesting. When you push your code to the repo in Azure DevOps, you can set up a pipeline that will automatically take that code and execute steps you define to deploy it. 
An example would be my use case. I write a Terraform plan on my iPad, push it to the Azure DevOps git repo, and the pipeline takes that code and uses it to deploy a new virtual machine on the server in my living room. 
Pipeline Punch
Pipelines are not free. You do get some free pipeline hours of execution every month, but if you go over the allotted free tier values it gets very expensive. 
One solution to this is to host your own pipeline and connect it to Azure DevOps. This means that instead of paying Microsoft to run this code, you have your own server that does it. This has a few benefits:
You can customize your server’s software
You can customize your server’s connectivity (such as a VPN that connects it to your house!) 
You have control over every aspect of the pipeline, and can configure it to your needs!
The pipeline agent doesn’t have to be anything super powerful, depending on what you’re doing. But you can beef it up if you need more power, or you can slim it down to the minimum if you just need something lightweight. 
I chose to run my pipeline agent on Digital Ocean. I will now go over the process of configuring a self hosted pipeline agent.
Setting up your own Custom Agent
First, you need a Linux server. I’m using Ubuntu 22.04 hosted on Digital Ocean for $6/month. This guide assumes you know how to install and configure a Linux server, so we won’t be covering that here. 
The process is pretty simple. Let’s set up Azure DevOps.
First you will need to navigate to your Azure DevOps instance and click the settings icon in the bottom left hand corner of the screen. 
Tumblr media Tumblr media
You will then be able to download the agent, or copy the link. If you copy the link, you can simply download the agent on your Linux sever using the wget command. wget https://vstsagentpackage.azureedge.net/agent/3.232.1/vsts-agent-linux-x64-3.232.1.tar.gz
You will need to do all of this from a non-root user with sudo permissions. 
Next execute these commands to set up the server.mkdir myagent && cd myagent tar zxvf ~/Downloads/vsts-agent-linux-x64-3.232.1.tar.gz
Now you will need to configure your personal access token in Azure DevOps. This PAT is going to be the password that allows your agent to receive code and commands from Azure DevOps. 
Tumblr media Tumblr media
Note that a PAT will expire after a set amount of time you can define. You can set it to never expire, but you really shouldn’t. 
Take a note of your PAT, you won’t be able to see it again after this. Also, take a note of your DevOps URL, it should look like dev.azure.com/patrick0980 
Next, connect to your pipeline agent server over SSH. You will run the following commands.cd myagent ./config.sh
This will guide you through the install process. You will be asked for your DevOps URL and PAT, so have those ready. 
Once you’ve finished filling out the forum for the installer, it will be present on your system. We’re almost there!
The last thing we need to do is configure the pipeline agent to operate as a systemd service. This will allow it to run in the background on the server, so we won’t have to manually invoke it. To do that you will run the “svc.sh” script in the same directory you were just in../svc.sh
Tumblr media
Conclusion
Azure DevOps is a great tool you can utilize to really automate a lot of things. The possibilities are endless – and you don’t have to pay an extra penny for it! I hope you found this guide useful and hope to make more content for you soon. 
Have a great rest of your day!
0 notes
swaginsondabs · 4 months
Text
I made a video
I made a video on how I plan to integrate DevOps practices into my homelab. Also there is an accompanying article I will post here as well. https://youtu.be/C4RYwidEG3g
0 notes
swaginsondabs · 4 months
Text
Tumblr media
Me rn. Pleaseeeee let me be safeeeee
43K notes · View notes
swaginsondabs · 5 months
Text
Hey guys what’s up just living large, who’s in charge around here?
1 note · View note