Skip to content

Not Working-Removing a package from chocolatey without attempting to uninstall the program #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
6 tasks done
joe-malicki opened this issue Mar 27, 2025 · 4 comments
Open
6 tasks done
Labels
Bug Issues where something has happened which was not expected or intended

Comments

@joe-malicki
Copy link

Checklist

  • I confirm there are no unresolved issues reported on the Chocolatey Status page.
  • I have verified this is the correct repository for opening this issue.
  • I have verified no other issues exist related to my problem.
  • I have verified this is not an issue for a specific package.
  • I have verified this issue is not security related.
  • I confirm I am using official, and not unofficial, or modified, Chocolatey products.

What You Are Seeing?

When using the "chocolatey.win_chocolatey" module with the following parameters to remove the package from chocolatey without attempting to uninstall the program is not working:
- name: Remove/Not Uninstall Chocolatey Package
chocolatey.chocolatey.win_chocolatey:
name: splunkforwarder
state: absent
choco_args: --skipautouninstaller
Have tried this also:
- name: Remove/Not Uninstall Chocolatey Package
chocolatey.chocolatey.win_chocolatey:
name: splunkforwarder
state: absent
choco_args:
--skipautouninstaller

What is Expected?

Running this task will Remove Package from Chocolatey but NOT uninstall the program:
- name: Remove/Not Uninstall Chocolatey Package
chocolatey.chocolatey.win_chocolatey:
name: splunkforwarder
state: absent
choco_args:
--skipautouninstaller

How Did You Get This To Happen?

  1. Running "choco uninstall splunkforwarder --skipautouninstaller" from the server itself DOES Remove from
    Chocolatey but NOT uninstall the program
  2. Ran Ansible Job with these parameters:
    • name: Remove/Not Uninstall Chocolatey Package
      chocolatey.chocolatey.win_chocolatey:
      name: splunkforwarder
      state: absent
      choco_args: --skipautouninstaller
  3. Have tried this also:
    • name: Remove/Not Uninstall Chocolatey Package
      chocolatey.chocolatey.win_chocolatey:
      name: package1
      state: absent
      choco_args:
      --skipautouninstaller
  4. JSON Output from Task shows the parameter being passed, but Autoinstaller is still running and uninstalling the package.

{
"changed": true,
"invocation": {
"module_args": {
"checksum_type": null,
"override_args": false,
"allow_prerelease": false,
"source_username": null,
"allow_multiple": false,
"timeout": 2700,
"remove_dependencies": false,
"proxy_url": null,
"source_password": null,
"proxy_password": null,
"checksum64": null,
"install_args": null,
"name": [
"splunkforwarder"
],
"checksum": null,
"version": null,
"skip_scripts": false,
"bootstrap_tls_version": [
"tls12",
"tls13"
],
"force": false,
"choco_args": [
"--skipautouninstaller"
],
"architecture": "default",
"proxy_username": null,
"pinned": null,
"validate_certs": true,
"ignore_checksums": false,
"allow_empty_checksums": false,
"bootstrap_script": null,
"checksum_type64": null,
"state": "absent",
"ignore_dependencies": false,
"source": null,
"package_params": null
}
},
"rc": 0,
"choco_cli_version": "1.4.0",
"stdout": "Chocolatey v1.4.0 Business\r\nUninstalling the following packages:\r\nsplunkforwarder\r\n\r\nsplunkforwarder v9.3.2.0\r\n Running auto uninstaller...\r\n Auto uninstaller has successfully uninstalled splunkforwarder or detected previous uninstall.\r\n splunkforwarder has been successfully uninstalled.\r\n\r\nChocolatey uninstalled 1/1 packages. \r\n See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).\r\n",
"stdout_lines": [
"Chocolatey v1.4.0 Business",
"Uninstalling the following packages:",
"splunkforwarder",
"",
"splunkforwarder v9.3.2.0",
" Running auto uninstaller...",
" Auto uninstaller has successfully uninstalled splunkforwarder or detected previous uninstall.",
" splunkforwarder has been successfully uninstalled.",
"",
"Chocolatey uninstalled 1/1 packages. ",
" See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log)."
],
"_ansible_no_log": false
}

System Details

  • Operating System: Windows 10 or Windows Server 2019/2022
  • Windows PowerShell version: 5.x
  • Chocolatey CLI Version: 1.4.0
  • Chocolatey Licensed Extension version: 1.40
  • Chocolatey License type: Business
  • Terminal/Emulator: PowerShell / Ansible

Installed Packages

PS C:\Windows\system32> choco list -lo
Chocolatey v1.4.0 Business
7zip 24.9.0
7zip.install 24.9.0
bloomberg 2.0.0.0
chocolatey 1.4.0
chocolatey-compatibility.extension 1.0.0
chocolatey-core.extension 1.4.0
chocolatey-license 2025.12.23.1800
chocolatey.extension 5.0.3
citrix-workspace 24.9.10.28
crowdstrike 7.16.18613.0
GoogleChrome 134.0.6998.178
jre8 8.0.4410.7
jre8x86 8.0.4410.7
microsoft-edge 134.0.3124.83
microsoft-teams 1.36.55205.0
notepadplusplus 8.7.7
notepadplusplus.install 8.7.7
webrtc 1.54.2408.19001
webview2-runtime 134.0.3124.85

Output Log

Sensitive data in log

Additional Context

No response

@joe-malicki joe-malicki added the Bug Issues where something has happened which was not expected or intended label Mar 27, 2025
@mwtrigg
Copy link

mwtrigg commented Mar 28, 2025

As the splunkforwarder package also includes a chocolateyUninstall.ps1 (see here: https://github.com/tnwinc/chocolatey-splunkforwarder/blob/master/tools/chocolateyuninstall.ps1), you need to also pass the --skip-powershell argument.

@joe-malicki
Copy link
Author

joe-malicki commented Mar 28, 2025

Hello...this really has nothing to do with the splunkforwarder package itself. Was using this as just an example. When using this module against any package that you just need to "remove" but not uninstall does not work. I reviewed the win_chocolatey.ps1 script in the module and from what I can see, the "choco_args" are not being passed when choosing "absent" for a state in the task.
chocolatey-ansible/chocolatey/plugins/modules/win_chocolatey.ps1
(upload not working for screenshots, so here are the lines I am referring to 173-189)


        # --allow-multiple is buggy for `choco uninstall`.
        # To get the correct behaviour, we have to use it only when multiple side by side package versions
        # are actually installed, or we'll either just get errors, or end up uninstalling all installed versions
        # even if a specific version is targeted.
        $useAllowMultiple = $packageInfo.$package.Count -gt 1
        $uninstallParams = @{
            ChocoCommand = $chocoCommand
            Package = $package
            Force = $force
            PackageParams = $package_params
            SkipScripts = $skip_scripts
            RemoveDependencies = $remove_dependencies
            Timeout = $timeout
            Version = $version
            AllowMultiple = $useAllowMultiple
        }
        Uninstall-ChocolateyPackage @uninstallParams

From the Chocolatey Docs for Uninstall, it would be passing the command as documented here directly to the choco.exe command, not as a package parameter: -n --skipautouninstaller
https://docs.chocolatey.org/en-us/choco/commands/uninstall/


NOTE:
A package with a failing uninstall can be removed with the -n --skipautouninstaller flags. This will remove the package from chocolatey without attempting to uninstall the program.


Re-noting that running "choco uninstall splunkforwarder -n --skipautouninstaller" from the server itself DOES Remove from
Chocolatey but NOT uninstall the program.


I am hoping this is the issue, but if I am mistaken, please let me know.
thanks for the help.....

@pauby
Copy link
Member

pauby commented Mar 31, 2025

choco_args:
--skipautouninstaller

That skips the Chocolatey Automatic Uninstaller from running. The software is still removed if Chocolatey can do so in other ways.

the "choco_args" are not being passed when choosing "absent" for a state in the task.

The "absent" state is to ensure the package, which includes the software, is absent. The Chocolatey Ansible module manages packages, so this is expected behaviour.

@joe-malicki
Copy link
Author

Thank you for the information. I understand what you are saying. I just feel that the module should have this capability, (remove package from Chocolatey and do not uninstall) but if it doesn't then it is what it is.
Maybe another "state" could be added? Called "remove" or something?
I know if I flat out run "choco uninstall packageX --skipautouninstaller" the package gets removed from Chocolatey but not uninstalled, so was just hoping I could do this with the module.
Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues where something has happened which was not expected or intended
Projects
None yet
Development

No branches or pull requests

3 participants