Hybrid OTel Deployment Windows & Linux
To scale your automation to include Windows Servers (for your IIS and SharePoint environments) alongside your Linux nodes, you need to update the Ansible playbook to use Windows-specific modules and define a structured inventory file.
1. Updated Ansible Playbook: deploy_otel_hybrid.yml
This playbook uses a block and when condition to distinguish between Linux and Windows hosts, ensuring the correct installation method for each.
YAML
---
- name: Hybrid Deployment of OTel Collector (Linux & Windows)
hosts: all
vars:
otel_win_version: "0.96.0"
otel_win_url: "https://github.com/open-telemetry/opentelemetry-collector-releases/releases/download/v{{ otel_win_version }}/otelcol-contrib_{{ otel_win_version }}_windows_amd64.msi"
tasks:
# --- WINDOWS SECTION (IIS / SharePoint / AD Nodes) ---
- name: Windows Deployment Block
block:
- name: Ensure Certs Directory exists on Windows
win_file:
path: 'C:\Program Files\OpenTelemetry Collector\certs'
state: directory
- name: Download and Install OTel Collector MSI
win_package:
path: "{{ otel_win_url }}"
state: present
- name: Deploy Windows OTel Config
win_template:
src: otel-config-win.yaml.j2
dest: 'C:\Program Files\OpenTelemetry Collector\config.yaml'
notify: Restart OTel Windows Service
- name: Ensure OTel Service is Running
win_service:
name: otelcol-contrib
start_mode: auto
state: started
when: ansible_os_family == "Windows"
# --- LINUX SECTION (Docker / K8s / Astro Nodes) ---
- name: Linux Deployment Block
block:
- name: Deploy Linux OTel Config
template:
src: otel-config-linux.yaml.j2
dest: "/etc/otelcol-contrib/config.yaml"
notify: Restart OTel Linux Service
when: ansible_os_family != "Windows"
handlers:
- name: Restart OTel Windows Service
win_service:
name: otelcol-contrib
state: restarted
- name: Restart OTel Linux Service
service:
name: otelcol-contrib
state: restarted
2. The Inventory File: inventory.ini
This file organizes your physical HP ProLiant servers, IIS farms, and Cloud nodes (AWS/Azure). It also specifies the connection parameters required for Ansible to communicate with Windows via WinRM.
Ini, TOML
[web_iis]
# Windows IIS & SharePoint Nodes
iis-server-01 ansible_host=10.0.1.10
iis-server-02 ansible_host=10.0.1.11
[linux_nodes]
# Docker & Node.js App Nodes
app-node-01 ansible_host=10.0.2.10
app-node-02 ansible_host=10.0.2.11
[physical_hardware]
# Physical HP ProLiant Servers managed via iLO
proliant-node-01 ansible_host=10.0.5.10
# Global Windows Variables (WinRM setup)
[web_iis:vars]
ansible_user=admin_user
ansible_password={{ vault_windows_password }}
ansible_connection=winrm
ansible_winrm_server_cert_validation=ignore
ansible_port=5986
# Global Linux Variables (SSH setup)
[linux_nodes:vars]
ansible_user=ubuntu
ansible_ssh_private_key_file=~/.ssh/id_rsa
3. Strategic Placement of Certs on Windows
For your DevSecOps workflow, the certificates issued by Smallstep CA should be placed in a directory where the OTel service account has read access.
- Path: C:\Program Files\OpenTelemetry Collector\certs\
- Automation: Use the win_copy module in Ansible to push the ca.crt, client.crt, and client.key from your secure GitHub Actions runner to these paths.
- Verification: Ensure the config.yaml on Windows points to these local paths using double backslashes (e.g., C:\\Program Files\\OpenTelemetry Collector\\certs\\ca.crt).
4. Summary of Architecture Benefits
- Infrastructure Consistency: Manages 10+ years of IIS and Windows Server history alongside modern Linux stacks using a single source of truth in GitHub.
- Security: Enforces Zero-Trust by automating certificate deployment across both OS types.
- Efficiency: Uses Ansible to eliminate manual configuration of HP ProLiant hardware and virtualized clusters.