Agent deployment failed with ansible template

We are deploying azdevops self hosted agent using ansible template but i see it failed with following error, Please suggest

fatal: [SERVER]: FAILED! => {“changed”: false, “cmd”: “cmd.exe /c type "C:\\Temp\\Azure-DevOps-ENV-Agent-Config-4279336.log"”, “delta”: “”, “end”: “”, “failed_when_result”: true, “rc”: 0, “start”: “”, “stderr”: “”, “stderr_lines”: , “stdout”: "Request Numbers:\n()\r\nINITIAL State of INPUT Parameters:\nazdoAgentType (ENVIRONMENT)\nazdoAgentName (SERVER-ENV-CIP-13713-F-QA)\nazdoAgentHome ()\nazdoAgentPool ()\nazdoProject (Chile Ins Presales and Sales ART)\nazdoDeploymentGroup ()\nazdoEnvironment (13713_metlifecl_pre_BackOffice_Digital_Front-qa)\nazdoWindowsAgentDownloadLink (https://download.agent.dev.azure.com/agent/4.264.2/vsts-agent-win-x64-4.264.2.zip)\nazdoOrgURL (nazdoAgentWorkFolder (_work)\nconfigOption (INSTALL)\r\nUPDATED state of INPUT Parameters:\nazdoAgentType (ENVIRONMENT)\nazdoAgentName (SERVER-ENV-CIP-bb)\nazdoAgentHome (D:/azagent-EN…

@tarun Welcome to the Ansible Forum.

  1. Is that the full error message, it appears to be truncated.
  2. Can you please include the task & template that triggered this error. Remember to redact any confidential information

This isn’t a bug in Ansible; the log shows that inputs are missing:

azdoAgentHome() azdoAgentPool()

Both are empty, which causes the Azure DevOps agent config to fail. Quick checks:

even in ENVIRONMENT mode, define azdoAgentPool

Before setting up, make sure azdoAgentHome exists.

make sure azdoOrgURL is complete

run the task as an administrator on Windows

The cmd.exe /c type failure just means that the config script stopped running before it was supposed to. This is usually caused by missing variables or bad input, not a problem with the platform.

I’ve seen this error before. It looks like the AzDO agent config task is running but failing due to some weird characters in the log file path. Try removing the quotes around the log file path in your ansible template. That usually fixes the issue.