Building Windows Servers with Azure DevOps Pipelines and Ansible
=================================================================
In this blog post, we will explore how to use Azure DevOps pipelines and Ansible to automatically deploy Windows Server Standard Operating Environments (SOE) onto vSphere. We will show you how to create a layered configuration that allows us to use the same Pre, Layer 0, and 1 for all core components, while only changing Layer 2 and POST as required for optional components such as Web servers, SQL servers, etc.
Introduction
————
Hello there! Do you want to build Windows servers like a boss? Well, you’ve come to the right place! In this post, we will explore how to use Azure DevOps pipelines and Ansible to automatically deploy Windows Server Standard Operating Environments (SOE) onto vSphere.
Before we begin, let me tell you that this is not a beginners guide, so if you’re new to DevOps or Ansible, I suggest you go back and learn the basics before coming here. That being said, lets get started!
Background
———-
First, let’s talk about why we need this. We all know that building Windows servers can be a pain, especially when it comes to keeping everything up-to-date and consistent. That’s where Azure DevOps and Ansible come in. With these tools, we can automate the process of deploying Windows servers, making it easier to keep everything up-to-date and consistent.
Tools Used
————-
To build these Windows servers like a boss, we will be using the following tools:
* Azure DevOps pipelines
* Ansible
Azure DevOps Pipelines
———————-
So, what are Azure DevOps pipelines? Well, they’re like a magical way to automate the deployment of your Windows servers. With Azure DevOps, we can create a pipeline that defines a sequence of steps to deploy our SOE. We can then use Ansible to automate the process of deploying our SOE onto vSphere.
Ansible
——-
Ansible is like the magic that makes it all work. With Ansible, we can define tasks that need to be done, and then use Ansible’s built-in modules to execute those tasks. For example, we can use the `win_install` module to install software, or the `win_feature` module to enable features on our Windows servers.
Layered Configuration
———————–
So, how do we create this magical pipeline? Well, we start by creating a layered configuration. What does that mean? It means we define different layers of components that need to be deployed, and then we use Ansible to automate the process of deploying those components onto vSphere.
Let’s break it down:
* Pre: This is where we define our variables and other settings that will be used throughout the pipeline.
* Layer 0: This is where we define our core components, such as Windows itself, and any other software we need to install.
* Layer 1: This is where we define our additional components, such as IIS web servers or SQL servers.
* Layer 2: This is where we define our optional components, such as Web servers or SQL servers.
* POST: This is where we define any post-deployment tasks that need to be done, such as joining the domain or updating software.
Variables
————
So, what kind of variables do we need? Well, here are a few examples:
* `build_number`: This variable will hold the build number for our SOE.
* `server_name`: This variable will hold the name of our server.
* `vm_name`: This variable will hold the name of our VM.
Now that we have an idea of what variables we need, let’s create them!
Creating Variables
—————–
So, how do we create these variables? Well, it’s easy! We just need to add them to our Azure DevOps pipeline and give them a value. For example:
* `build_number`: We can set this to the current build number for our SOE.
* `server_name`: We can set this to the name of our server, such as “web-01”.
* `vm_name`: We can set this to the name of our VM, such as “web-01-vm”.
Creating Pipelines
——————-
Now that we have our variables defined, let’s create our pipelines!
So, how do we create a pipeline? Well, it’s easy! We just need to click the “New Pipeline” button in Azure DevOps and select “Existing Azure Repo YAML file”. Then, we can specify the path to our pipeline definition file (i.e. `vmanw-web-server-automation.yml`).
Once we have created our pipeline, we can run it! But before we do that, let me tell you about the magic that happens behind the scenes.
Ansible Magic
——————
So, what happens when we run our pipeline? Well, Ansible takes over and automates the process of deploying our SOE onto vSphere. It does this by using modules such as `win_install` or `win_feature` to install software and enable features on our Windows servers.
Conclusion
———-
And there you have it! With these tools, we can automate the process of deploying Windows servers like a boss! So, go ahead and give it a try, and let me know what you think in the comments below. Happy building!