ansible: run an nsis uninstaller silently

591 Views Asked by At

A Windows application has been installed using an NSIS installer on a target machine under C:\Program Files\my_app\. In that folder there is also the uninstaller Uninstall.exe. I'm trying to write an ansible task that will run that uninstaller silently. The connection to that target machine is done using

ansible_connection: winrm

Running the following command manually on the target machine using a cmd prompt removes the application successfully and silently:

"C:\Program Files\my_app\Uninstall.exe" /S

However, when trying to implement my ansible task I cannot get it working. I've tried the following

  win_shell: '"C:\Program Files\my_app\Uninstall.exe" /S'
    args:
      executable: cmd

and

win_command: '"C:\Program Files\my_app\Uninstall.exe" /S'

Both of these tasks complete without an error, but the application is not uninstalled. This is the relevant output when running these tasks:

{
"start": "2021-11-13 08:37:57.146265",
"stdout": "",
"cmd": "\"C:\\Program Files\\my_app\\Uninstall.exe\" /S",
"stderr": "",
"changed": true,
"rc": 0,
"delta": "0:00:00.533985",
"end": "2021-11-13 08:37:57.680251",
"stdout_lines": [],
"stderr_lines": [],
"_ansible_no_log": false
}

What am I missing here? Many thanks

EDIT

The installer doesn't create an entry at the windows registry so using the ansible 'win_package' is not applicable as there is no 'product_id' I can use.

1

There are 1 best solutions below

0
On

i am using that to desinstall some packages:

- name: Uninstall my_app
  ansible.windows.win_package:
    path: C:\Program Files\my_app\Uninstall.exe
    product_id: my_app # -> to adapt 
    arguments: /S
    state: absent

you could even test without path:

- name: Uninstall my_app
  ansible.windows.win_package:
    product_id: my_app # -> to adapt 
    arguments: /S
    state: absent