# About running Ansible playbook via azure pipeline on windows agent machine

**URL:** <https://forum.ansible.com/t/about-running-ansible-playbook-via-azure-pipeline-on-windows-agent-machine/45929>\
**Category:** Get Help\
**Tags:** azure, windows, ansible-project\
**Created:** [June 16, 2026, 1:30pm UTC](https://forum.ansible.com/t/about-running-ansible-playbook-via-azure-pipeline-on-windows-agent-machine/45929 "2026-06-16T13:30:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![VaibhavBagadiya](https://avatars.discourse-cdn.com/v4/letter/v/977dab/32.png) [@VaibhavBagadiya](https://forum.ansible.com/u/VaibhavBagadiya)\
**Post date:** [June 16, 2026, 1:30pm UTC](https://forum.ansible.com/t/about-running-ansible-playbook-via-azure-pipeline-on-windows-agent-machine/45929/1 "2026-06-16T13:30:09Z")

</div>

Right now I just want to create topic and subscription for azure service bus via ansible from azure pipeline. My pipeline use windows based agent and I am able to install ansible but not able to run playbooks like create topic and subscription for azure service bus.

Also I am providing here my code.

trigger:  
batch: true  
branches:  
include:  
- main  
paths:  
include:  
- Server.Modern  
exclude:  
- ‘Server.Modern/README.md’  
- ‘Server.Modern/SETUP.md’  
- ‘Server.Modern/.gitignore’

pool:  
name: ‘NonProd-NEU’

variables:

- group: REDACTED\_VARIABLE\_GROUP\_1
- group: REDACTED\_VARIABLE\_GROUP\_2
- group: REDACTED\_VARIABLE\_GROUP\_3
- group: REDACTED\_VARIABLE\_GROUP\_4
- group: REDACTED\_VARIABLE\_GROUP\_5
- template: ‘variables/variables-server-modern-qa.yml’
- name: appName  
value: ‘server-modern’
- name: dotnetVersion  
value: ‘10.x’

stages:

- stage: ‘TestAnsible’  
displayName: ‘TEST: Ansible Service Bus Provisioning’

jobs:  
- deployment: TestAnsibleJob  
displayName: ‘Test Ansible Provisioning ONLY’  
environment: ‘SC Server Modern QA’

```
  strategy:
    runOnce:
      deploy:
        steps:

          - script: echo "=== ANSIBLE TEST MODE - Service Bus Provisioning Only ==="
            displayName: 'TEST MODE Banner'

          - checkout: self
            displayName: 'Checkout source code'
            fetchDepth: 1

          - powershell: |
              Write-Host "Agent Name: $(Agent.Name)"
              Write-Host "Machine Name: $(Agent.MachineName)"
              Write-Host "Agent Version: $(Agent.Version)"
            displayName: 'Show Agent Information'

          - pwsh: |
              Write-Host "PowerShell Version:"
              $PSVersionTable.PSVersion
            displayName: 'Verify UTF8 Under PowerShell 7'

          - pwsh: |
              $env:PYTHONUTF8 = "1"
              $env:PYTHONIOENCODING = "utf-8"
            displayName: 'Verify UTF8 Environment Variables'

          - pwsh: |
              $env:PYTHONUTF8 = "1"
            displayName: 'Verify Python UTF8 Mode'

          - pwsh: |
              Write-Host "POWERSHELL DIAGNOSTICS"
              Write-Host "PYTHON DIAGNOSTICS"
              python --version
            displayName: 'Check PowerShell/Python/Ansible Diagnostics'

          - pwsh: |
              chcp 65001 | Out-Null

              $env:PYTHONUTF8 = "1"
              $env:PYTHONIOENCODING = "utf-8"

              $env:ANSIBLE_SKIP_CONFLICT_CHECK = "1"
              $env:ANSIBLE_FORCE_COLOR = "0"

              python --version

              python -m pip install --user --upgrade pip setuptools wheel --quiet
              python -m pip install --user ansible==10.6.0 --quiet

              python -m pip install --user azure-identity azure-core azure-mgmt-servicebus --quiet
            displayName: 'Setup Ansible (Sanitized)'

          - pwsh: |
              chcp 65001 | Out-Null

              $env:PYTHONUTF8 = "1"
              $env:PYTHONIOENCODING = "utf-8"

              $ansibleRoot = Join-Path "$(Build.SourcesDirectory)" "Infrastructure" "ansible"
              Set-Location $ansibleRoot

              function Invoke-Playbook {
                  param (
                      \[string\]$Playbook,
                      \[string\]$Inventory,
                      \[int\]$Retries = 2
                  )

                  for ($i = 1; $i -le $Retries; $i++) {

                      cmd /c "set PYTHONUTF8=1 && set PYTHONIOENCODING=utf-8 && python -X utf8 -m ansible.cli.playbook $Playbook -i $Inventory -v"

                      if ($LASTEXITCODE -eq 0) {
                          return
                      }
                  }

                  throw "Playbook failed: $Playbook"
              }

              $inventory = "inventories/qa.yml"

              Invoke-Playbook "playbooks/create-topics.yml" $inventory
              Invoke-Playbook "playbooks/create-subscriptions.yml" $inventory
              Invoke-Playbook "playbooks/create-queues.yml" $inventory
            displayName: 'Provision Service Bus (QA)'
            env:
              AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
              AZURE_CLIENT_ID: $(AZURE_CLIENT_ID)
              AZURE_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
              AZURE_TENANT_ID: $(AZURE_TENANT_ID)

          - script: echo "=== ANSIBLE TEST COMPLETE ==="
            displayName: 'TEST COMPLETE Banner'

```

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [June 16, 2026, 5:58pm UTC](https://forum.ansible.com/t/about-running-ansible-playbook-via-azure-pipeline-on-windows-agent-machine/45929/2 "2026-06-16T17:58:27Z")

</div>

ansible cannot be run from Windows. See the following link:

> **[Control node requirements - Installing Ansible — Ansible Community...](https://docs.ansible.com/projects/ansible-core/devel/installation_guide/intro_installation.html#control-node-requirements)**
>
> Ansible is an agentless automation tool that you install on a single host (referred to as the control node).

---

<div class="post-metadata">

**Author:** ![ifloresv86](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ifloresv86/32/10844_2.png) [@ifloresv86](https://forum.ansible.com/u/ifloresv86)\
**Post date:** [June 16, 2026, 7:02pm UTC](https://forum.ansible.com/t/about-running-ansible-playbook-via-azure-pipeline-on-windows-agent-machine/45929/3 "2026-06-16T19:02:16Z")

</div>

Here are two related posts that might be helpful, although the answer is basically the same as what @sivel already provided (at least natively it’s not possible on Windows):

> [@Run Ansible on Windows](https://forum.ansible.com/t/run-ansible-on-windows/44412):
>
> We have the use case where we need to prep a Windows VM from within. We are not allowed to open up any services to remotely managed the VM. Would Ansible still be a fit? The runbooks are fairly easy: Installing some choco packages Installing some windows features configuring IIS mounting some fileshares, configuring permissions on the fileshares I see two options: Run Ansible from the Windows host. I have seen some documentation somewhere that this is highly discouraged. All kinds of depen…

> [@Using WSL with Ansible and RHEL to develop Automation Content](https://forum.ansible.com/t/using-wsl-with-ansible-and-rhel-to-develop-automation-content/39720):
>
> As a services leader for our public sector customers here at Red Hat, I find myself in an odd situation. Many of my customers require connecting through remote access tools only available on Windows. For my own simplicity, I run with Windows 11 as my daily driver, using it for everything I do, and with the power of Windows Subsystem for Linux, I’m able to do everything my counterparts with Linux or Mac desktops can. Why develop on Windows? Quite often in business environments, Windows is the st…
