Standardized Environment Deployment with Ansible

Lab Guide - Scenario 02: Standardized Consistency

1. Introduction

Ready to dive into real automation? You’ve been tasked with configuring a new environment for multiple teams using standardized, consistent deployments. This scenario demonstrates how Ansible Automation Platform enables different technology teams to collaborate effectively by using pre-built playbooks and templates.

By leveraging workflow templates, job templates, and secure credential management, you’ll deploy and configure everything consistently across your infrastructure, minimizing manual intervention and ensuring accuracy.

1.1. Learning Objectives

By the end of this lab, you will be able to:

  • Create and execute workflow templates that orchestrate multiple job templates

  • Implement secure credential management using Ansible Vault

  • Deploy standardized configurations across Windows and Linux environments

  • Manage infrastructure as code through automated inventory management


2. Lab Environment Setup

2.1. Access Credentials

Username Password

admin

ansible123!

2.2. Server Information

Your DNS domain for this lab is: {dns_domain}

Server FQDN

Domain Controller

windows.{dns_domain}

Dev Windows Server

dbserver.{dns_domain}


3. Exercise 1: Baseline Configuration and Applications

3.1. Understanding the Request

Support Ticket 001

You’ve received a support ticket requesting configuration updates for two Windows servers in the UAT (User Acceptance Testing) environment. The requirements include:

  • Deploy a standard set of applications

  • Apply specific registry changes for environment compliance

  • Disable automatic updates to ensure stability

  • Prevent unintended changes during testing phases

To address this request efficiently, you’ll create a workflow template that combines multiple job templates into a logical, repeatable process.

3.2. Step 1: Create a Workflow Template

  1. Navigate to Automation Execution → Templates

  2. Click Create template

  3. Select Create workflow job template

Workflow Configuration:

Field Value

Name

Windows Apps and Settings

Organization

Default

Description

Required Applications and Settings

Inventory

Windows Servers

  1. Click Create workflow template

This will open the Workflow Visualizer where you’ll design your automation workflow.

3.3. Step 2: Add the First Workflow Step

  1. In the Workflow Visualizer, click Add Step

Workflow Creation Interface

First Step Configuration:

Field Value

Node Type

Job Template

Job Template

Windows Registry keys

Convergence

Any

  1. Click Next and Finish

3.4. Step 3: Add the Second Workflow Step

  1. Select the ... menu on your first step

  2. Click Add step and link

Workflow Step Configuration

Second Step Configuration:

Field Value

Node Type

Job Template

Job Template

Windows Server Applications

Status

Always run

Convergence

Any

  1. Click Next and Finish

  2. Select Save to save the workflow

3.5. Step 4: Execute the Workflow

  1. Navigate to Automation Execution → Templates

  2. Select the Windows Apps and Settings workflow

  3. Click Launch template

Monitor the workflow execution in the output. You’ll observe how the workflow orchestrates multiple job templates:

  • First: Windows Registry keys configuration (completes with green checkmark)

  • Then: Windows Server Applications installation (blue spinning arrows while running)

Workflow Execution Status

The complete workflow takes approximately 3-4 minutes. Both Windows servers will be configured with necessary registry changes and applications required by development teams.

3.6. Step 5: Verify Application Deployment

  1. Click on the Windows Server Applications icon in the Visualizer

  2. Review the job output to verify deployed applications

  3. Notice packages like procexp, windirstat, and other development tools have been installed

Application Installation Results

4. Exercise 2: Domain Controller Configuration

4.1. Understanding the New Request

Support Ticket 002

A new infrastructure request has arrived from the operations team:

  • Configure one Windows server as a domain controller

  • Prepare another server for database services

  • Ensure compliance with organizational policies

Your Windows SMEs have provided job templates to deploy this environment consistently.

4.2. Step 1: Verify Current Server State

  1. Navigate to the Windows tab

  2. Click the Start/Windows button and open Server Manager

  3. Select Local Server

  4. Verify the server is currently part of the default WORKGROUP with limited services

Current Server Configuration

4.3. Step 2: Configure Secure Credentials

  1. Navigate to your AAP tab

  2. Go to Automation Execution → Templates

  3. Edit the Windows Domain Controller template

Your Windows team has provided an Ansible Vault for secure credential storage. This ensures Active Directory credentials remain encrypted and protected.

Adding Vault Credentials:

  1. Click Edit template

  2. In the Credentials section, add the Windows Vault credential

  3. Save the job template

Vault Credential Configuration

Ansible Vault credentials ensure sensitive information remains encrypted and secure. You don’t have direct access to the credentials, maintaining security best practices.

4.4. Step 3: Deploy Active Directory

  1. Launch the job template using Launch template

  2. Monitor the output as each task executes

Domain Configuration Process

The template will display the domain/forest information generated by the environment. Record this domain detail for future reference.

This process takes several minutes to deploy Active Directory and reboot the system. After reboot, default Group Policies will also be applied.

4.5. Step 4: Verify Domain Controller Configuration

After the system reboots:

  1. Click Start/Windows and open Server Manager

  2. Verify the domain now reflects your DNS domain from the template output

  3. Confirm that DNS and Active Directory services are running

Active Directory Services Configuration

5. Exercise 3: RHEL Server Deployment

5.1. Expanding Infrastructure

With Active Directory configured and Windows servers deployed, the next step involves deploying a RHEL system for streaming applications. Your standardized build templates will streamline this process.

This exercise simulates provisioning tasks. In production environments, you would customize instance configurations to meet specific requirements.

5.2. Step 1: Review Current Inventory

  1. Navigate to Automation Execution → Infrastructure → Inventories

  2. Examine existing inventories:

    • Network environments

    • Windows environments

    • Video Platform Inventory (currently contains only a loadbalancer group)

Current Inventory State

You need to deploy a RHEL system and configure a webservers group for future use.

5.3. Step 2: Deploy New Node

  1. Navigate to Automation Execution → Templates

  2. Launch the Deploy Node template

  3. When prompted for the node name, enter: node01

  4. Submit the job

In this simulated environment, we use configuration as code to build inventory. With inventory plugins, you could synchronize against an inventory source.

5.4. Step 3: Verify Inventory Updates

  1. Once the job completes, navigate to Automation Execution → Infrastructure → Inventories

  2. Observe the new webservers group with your new node in the Video Platform Inventory

Updated Inventory State

6. Code Reference

6.1. Windows Application Installation with Chocolatey

Here’s the automation code for installing standardized Windows applications:

tasks:
  - name: Ensure Chocolatey is installed
    win_chocolatey:
      name: chocolatey
      state: present

  - name: Install multiple packages sequentially
    win_chocolatey:
      name: '{{ item }}'
      state: present
    loop:
      - procexp
      - windirstat
      - 7zip
      - git
      - python

  - name: Check python version
    ansible.windows.win_command: python --version
    register: check_python_version

  - name: Show python version
    ansible.builtin.debug:
      msg: Python Version is {{ check_python_version.stdout_lines[0] }}

6.2. Domain Controller Promotion

Here’s the code for promoting Windows servers to domain controllers:

tasks:
  - name: Ensure local Administrator account has a password
    ansible.windows.win_user:
      name: "{{ username }}"
      password: "{{ user_password }}"

  - name: Promote system to a domain Controller
    microsoft.ad.domain:
      dns_domain_name: "{{ wins_domain }}"
      safe_mode_password: "{{ safe_password }}"
      domain_mode: Win2012R2
      forest_mode: Win2012R2
      reboot: true

  - name: Firewall rule to allow RDP on TCP port 5986
    win_firewall_rule:
      name: WinRM
      localport: 5986
      action: allow
      direction: in
      protocol: tcp
      profiles: domain,private,public
      state: present
      enabled: yes