0

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.

bahrep
  • 29,961
  • 12
  • 103
  • 150
Nahuster
  • 13
  • 6
  • You need the same account on both local and remote machine. Best if the account is an Admin. With admin you use a dollar sign instead of a colon in the path name so indicate the account is Admin. So use : C$\SW\ – jdweng Dec 30 '22 at 15:04
  • Sorry for the delay on this but it did not work. I've tried what you sugested and quite a few other options and it's still making me crazy. – Nahuster Jan 04 '23 at 07:40
  • I just tried this: - name: Install Qualys Agent on the machine ansible.builtin.raw: Invoke-Command -ScriptBlock {& cmd /c C:\\_IDTDeploy\\SW\\Qualys\\QualysCloudAgent_4.6.1.6.exe CustomerId="'{'{{customer_id}}'}'" ActivationId="'{'{{activation_id}}'}'" WebServiceUri="http://qagpublic.qg2.apps.qualys.eu/CloudAgent/"} – Nahuster Jan 04 '23 at 07:41
  • Windows shell is going to run cmd.exe and not powershell.exe. You need to run equivalent to : cmd.exe powershell.exe arguments – jdweng Jan 04 '23 at 09:52
  • Hello @jdweng, thanks for your replies! I already tried it as a CMD script, without the first bit which is from powershell Tried this as well ansible.builtin.win_command: cmd: C:\_IDTDeploy\SW\Qualys\QualysCloudAgent4.6.1.6\QualysCloudAgent_4.6.1.6.exe arguments: - CustomerId='{'{{customer_id}}'}' - ActivationId='{'{{activation_id}}'}' - WebServiceUri={{uripath}} Still no luck, doesn't seem to want to install this thing through ansible. I think it may be due to the parameters but the installers we have won't run if you don't use those parameters. – Nahuster Jan 05 '23 at 15:46
  • I would create a argument string so the curly brackets do not get misinterpreted : $arguments = "CustomerId={xxxxxxxxxxxxx} ActivationId={xxxxxxxxxxxx} WebServiceUri= https://qagpublic.qg2.apps.qualys.eu/CloudAgent/" Then use : C:_IDTDeploy\SW\Qualys\QualysCloudAgent4.6.1.6\QualysCloudAgent_4.6.1.6.exe $arguments. Note that the path name is missing the backslash "c:\" So the executable is relative to where you are running the command when you do not have the backslash. – jdweng Jan 05 '23 at 16:03

0 Answers0