Page MenuHome GnuPG

Can't uninstall gpg4win with Ansible
Open, NormalPublic

Description

I am able to successfully install gpg4win with ansible for my users. However uninstalling is an issue. I have tried uninstalling with both the ansible uninstall module (win_package) and by running the uninstaller in an admin powershell silently. They both do not uninstall. I attached the two ansible snippets I have tried below. I have also tried many variations of these two but nothing has worked. The need for the uninstall is because for some users Right click -> Sign and encrypt no longer appears. When I uninstall and reinstall this functionality works again. All this is on Windows 10.

- name: Uninstall gpg4win from the registry
  ansible.windows.win_package:
    product_id: 'Gpg4win'
    arguments: /S
    state: absent
- name: Uninstall gpg4win from the exe
  ansible.windows.win_shell: |
    & "C:\Program Files (x86)\Gpg4win\gpg4win-uninstall.exe" /S

Here is my working ansible install code for gpg4win.

install_dir: '{{ ansible_env.SystemDrive }}\Ansible'
install_url: 'https://files.gpg4win.org/gpg4win-4.0.0.exe'
install_file: 'gpg4win-4.0.0.exe'
- name: 'Download gpg4win to Ansible Directory'
  ansible.windows.win_get_url:
    url: '{{ install_url }}'
    dest: '{{ install_dir }}\{{ install_file }}'
  register: 'downloaded_file'

- name: 'Ensure gpg4win is installed'
  ansible.windows.win_package:
    path: '{{ downloaded_file.dest }}'
    arguments: '/S'
    product_id: 'Gpg4win'

Details

Version
4.0.0

Event Timeline

werner triaged this task as Normal priority.May 5 2022, 8:41 AM
- name: Uninstall gpg4win from the registry
  ansible.windows.win_package:
    product_id: 'Gpg4win'
    arguments: /S
    state: absent

From a quick glance at the docs. This looks completely correct. What did this do and what didn't it do?

FWIW: as mentioned in T7452#195891, it might be necessary to manually copy the uninstaller to a temporary directory ({{ tmp_uninstall_exe }}) and call it from there to get a clean uninstall:

- name: uninstall gpg4win
  ansible.windows.win_package:
    path: "{{ tmp_uninstall_exe }}"
    product_id: Gpg4win
    arguments: /S _?={{ gpg4win_dir }}
    state: absent