Architecting Enterprise Windows Automation with Ansible and Microsoft Endpoint Configuration Manager

The integration of Ansible with Microsoft Endpoint Configuration Manager (MECM), historically known as System Center Configuration Manager (SCCM), represents a paradigm shift in how enterprise Windows environments are managed. Rather than viewing these tools as competing entities, the modern architectural approach treats Ansible as a supplemental automation engine that orchestrates the services provided by MECM. While MECM remains a powerhouse for endpoint management and software distribution, Ansible provides the agility of infrastructure-as-code, allowing administrators to treat their Windows fleet with the same programmatic rigor typically reserved for Linux environments. This synergy allows organizations to bridge the gap between traditional Windows management and a broader, unified automation strategy, reducing manual overhead and ensuring strict consistency across diverse environments.

The Conceptual Framework of Ansible and MECM Coexistence

It is a critical technical distinction that Ansible is not designed to be a replacement for System Center Configuration Manager (SCCM) or package managers like Chocolatey. Instead, it functions as a supplemental tool. This means that while SCCM continues to handle the heavy lifting of endpoint imaging, software distribution, and complex client-side policy management, Ansible orchestrates the automation of the services that this software provides.

The relationship is one of orchestration versus management. MECM manages the state of the endpoint, while Ansible manages the configuration of the MECM infrastructure itself and coordinates the triggering of MECM actions. By utilizing Ansible, administrators can automate the deployment of software updates and configuration changes through playbooks, using MECM as the authoritative source of truth for the environment's state.

Technical Prerequisites and Connectivity for Windows Automation

To establish a functional link between an Ansible control machine and Windows targets, the environment must be configured for remote management. The primary mechanism for this is the Windows Remote Manager (WinRM). Without a properly configured WinRM listener, Ansible cannot push configurations or execute modules on the target Windows hosts.

The Ansible team has provided a standardized method to streamline this setup via a specialized PowerShell script named ConfigureRemotingForAnsible. This script is designed to automate the configuration of WinRM on any supported Windows server or client target, removing the manual complexity of setting up listeners and firewall rules.

To implement this configuration, the following sequence must be executed within Windows PowerShell:

powershell $url = "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1" $file = "$env:temp\ConfigureRemotingForAnsible.ps1" (New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file) powershell.exe -ExecutionPolicy ByPass -File $file winrm enumerate winrm/config/Listener

The final command, winrm enumerate winrm/config/Listener, is used to verify that the listener has been successfully created and is active. Once connectivity is established, Ansible can utilize various authentication transport schemes to secure the communication channel. These include:

  • NTLM (NT LAN Manager)
  • Kerberos
  • Basic authentication

Deep Dive into the Microsoft MECM Certified Collection

The microsoft.mecm collection is a specialized set of tools developed to provide a bridge between the Red Hat Ansible Automation Platform and the Configuration Manager site server. This collection consists of 26 modules and one plug-in, allowing administrators to programmatically interact with MECM infrastructure.

The primary objective of the microsoft.mecm collection is to allow the Ansible Automation Platform to use MECM as the "source of truth." This means that instead of manually clicking through the MECM console to deploy a patch or update a group, an administrator can define the desired state in a YAML playbook, and Ansible will interact with the MECM site server to execute the task.

Core Capabilities and Module Functionality

The collection focuses heavily on patch management and orchestration, providing granular control over how Windows updates are handled across the enterprise. Two pivotal modules within this collection are:

  • software_update_group: Used to create and manage groups of software updates.
  • software_update_deployment: Used to programmatically deploy these update groups to specific targets.

By leveraging these modules, organizations can move away from manual update scheduling and instead implement a fully automated pipeline for security patching, ensuring that all servers are compliant with corporate security policies without manual intervention.

Advanced Deployment via Ludus and Synzack Collections

For those operating in lab or testing environments, the synzack.ludus_sccm collection provides a comprehensive set of roles to install and configure SCCM from the ground up. This is particularly useful for creating "ranges" or simulated corporate environments using the Ludus platform.

Included Roles for Infrastructure Deployment

The synzack.ludus_sccm collection includes several roles that handle the entire lifecycle of an SCCM installation:

  • synzack.ludus_sccm.disable_firewall: Prepares the network environment by disabling restrictive firewall settings.
  • synzack.ludus_sccm.enable_webdav: Enables WebDAV for specific content distribution needs.
  • synzack.ludus_sccm.install_adcs: Installs Active Directory Certificate Services, which are often required for secure MECM communication.
  • synzack.ludus_sccm.ludus_sccm_distro: Manages the distribution point configuration.
  • synzack.ludus_sccm.ludus_sccm_mgmt: Sets up the management point.
  • synzack.ludus_sccm.ludus_sccm_siteserver: Installs and configures the primary site server.
  • synzack.ludus_sccm.ludus_sccm_sql: Deploys the SQL Server instance required for the MECM database.

Configuration and Installation Workflow

To deploy this collection within a Ludus environment, the following installation path is used:

bash ludus ansible collection add synzack.ludus_sccm

For manual installation or custom builds, the following process is employed to move the collection to the Ludus host:

bash git clone https://github.com/Synzack/ludus_sccm ansible-galaxy collection build python3 -m http.server 80 ludus ansible collection add http://<network ip>/synzack-ludus_sccm-1.0.0.tar.gz export LUDUS_USER_NAME=$(ludus user list --json | jq -r '.[].proxmoxUsername') ssh root@<ludus-host> "mkdir -r /opt/ludus/users/$LUDUS_USER_NAME/.ansible/collections/ansible_collections/synzack/ludus_sccm" rsync -av --exclude .git/ ./

Ludus SCCM Configuration Parameters

The deployment is governed by a configuration file, typically sccm-range-config.yml. This file defines critical operational parameters for the SCCM environment:

Parameter Description
ludus_sccm_enable_active_directory_forest_discovery Enables the discovery of AD forests
ludus_sccm_enable_active_directory_boundary_creation Automates the creation of AD boundaries
ludus_sccm_enable_subnet_boundary_creation Automates the creation of subnet boundaries
ludus_sccm_enable_active_directory_group_discovery Enables discovery of AD groups
ludus_sccm_enable_active_directory_system_discovery Enables discovery of AD systems
ludus_sccm_enable_active_directory_user_discovery Enables discovery of AD users
ludus_sccm_enable_pxe Enables Preboot Execution Environment (PXE) booting
ludus_enable_pxe_password Determines if a password is required for PXE
ludus_pxe_password Sets the specific password for PXE access
ludus_domain_join_account The account used to join machines to the domain
ludus_domain_join_password The password for the domain join account
ludus_sccm_win11_iso_path The full path to the Windows 11 ISO on the Ludus host

To apply this configuration and deploy the lab, the following commands are used:

bash ludus range config set -f sccm-range-config.yml ludus range deploy

It is important to note a known technical limitation: due to specific issues within SCCM, the use of .local domain suffixes will not work properly and should be avoided. Additionally, when updating the SQL Server cache (specifically moving to SQL Server 2022 Eval due to authentication breaks in Takeover 1), users must remove the enu_sql_server_2022_standard_edition_x64_dvd_43079f69.iso from /opt/ludus/resources/sccm/ on the Ludus host and rebuild the lab.

Agentless Automation and the Windows Ecosystem

Ansible's primary architectural advantage is its agentless nature. Unlike MECM, which requires a client agent installed on every target machine, Ansible communicates with Windows targets using standard remote access protocols. By default, Ansible utilizes Secure Shell (SSH) for communication, but for Windows, it primarily relies on WinRM to execute PowerShell commands.

This approach allows Windows administrators to use the same automation logic they would apply to Linux systems. Because Ansible modules for Windows natively support PowerShell, the automation feels familiar to those experienced with the Windows command line. The desired state of the system is described in YAML, and Ansible automatically handles the transitions to reach that state.

Resolving Conflicts: Ansible vs. SCCM/WSUS

In complex environments, conflicts can arise when both Ansible and SCCM (or WSUS) attempt to manage the same function, such as Windows updates. A common challenge is the overlap in version requirements when trying to isolate specific servers into an Ansible_WSUS group versus an SCCM_WSUS setup.

To resolve these conflicts, administrators can utilize WMI (Windows Management Instrumentation) filters within Group Policy Objects (GPOs). By using the Group Policy Management MMC snap-in, a WMI filter can be created and assigned to a GPO to ensure that a specific policy only applies to devices running a specific version of Windows.

However, this method is only effective if there is no overlap in the Windows versions between the servers intended for Ansible management and those intended for SCCM management. If the versions are identical, WMI filtering cannot distinguish between the two groups, and a different method of segmentation must be employed.

Conclusion

The integration of Ansible with Microsoft Endpoint Configuration Manager creates a powerful hybrid management layer that combines the robustness of a dedicated endpoint management suite with the flexibility of modern DevOps automation. By utilizing the microsoft.mecm certified collection, organizations can transition from manual, GUI-driven administration to a programmatic, version-controlled infrastructure. Whether deploying a full-scale lab via the Ludus project or orchestrating patch management across thousands of production servers, the key lies in correctly configuring the WinRM transport layer and treating Ansible as the orchestrator of MECM's capabilities. This synergy not only reduces the risk of human error but also ensures that the Windows environment can scale with the same efficiency as a cloud-native Linux deployment.

Sources

  1. Ansible Windows Admin
  2. Microsoft MECM Ansible Collection
  3. Ludus SCCM Collection
  4. Automating MECM with Red Hat Ansible
  5. Automate Microsoft Windows with Ansible
  6. SCCM vs Ansible Conflict - Microsoft Q&A

Related Posts