How can I pass a powershell command in Ansible with parameters

304 views Asked by At

I'm having trouble installing this particular agent in win servers through Ansible.

- name: "Installing agent {{agent}} and webservices"
  register: executed_script
  win_shell: Invoke-Command -ScriptBlock {& cmd /c C:\SW\{{agent}}\QualysCloudAgent4.6.1.6\QualysCloudAgent_4.6.1.6.exe CustomerId='{{customer_id}}' ActivationId='{{activation_id}}' WebServiceUri="http://qagpublic.qg2.apps.qualys.eu/CloudAgent/"}

This is the same command I use in a powershell script which works:

Invoke-Command -ScriptBlock {& cmd /c .\QualysCloudAgent_4.6.1.6.exe CustomerId=$CId ActivationId=$AId WebServiceUri="http://qagpublic.qg2.apps.qualys.eu/CloudAgent/"}

I've tried changing the places of the apostrophes, adding them, taking them away, hardcoding the customer_id and activation_id.

This is the command sent to us by the company to install it directly:

%BINARY_LOCATION%\QualysCloudAgent.exe CustomerId={xxxxxxxxxxxxx} ActivationId={xxxxxxxxxxxx} WebServiceUri= https://qagpublic.qg2.apps.qualys.eu/CloudAgent/

Does anybody know how to sort this out?

I already tried changing the syntax in several different ways, I've tried different ways to run it in ansible, also tried with msiexec in the powershell script bit. The part I don't get is why does it work on the ps1 script and it won't work on ansible with the same script. I have a few other agents that work properly with the same syntax.

0

There are 0 answers