Skip to content

(#187) Fix installing multiple packages with force#188

Open
Windos wants to merge 1 commit intochocolatey:masterfrom
Windos:GH-187/install-list-with-force
Open

(#187) Fix installing multiple packages with force#188
Windos wants to merge 1 commit intochocolatey:masterfrom
Windos:GH-187/install-list-with-force

Conversation

@Windos
Copy link
Copy Markdown
Member

@Windos Windos commented Jan 21, 2026

Description Of Changes

This PR ensures that lists of packages are still treated as lists when provided alongside the Force flag on win_chocolatey.

Additionally, tests have been added to cover the failure case that this change fixes.

Motivation and Context

Currently, when using the force flag on the win_chocolatey command the list of packages is being added to the collection of missing packages as a single string. This results in the packages being passed to choco.exe bounded by quote character (e.g. "package1 package2") and so this is being interpreted as a single (incorrect) package name.

Testing

---
- hosts: testvm
  gather_facts: true

  tasks:
  - name: Install list of software
    chocolatey.chocolatey.win_chocolatey:
      name:
        - 7zip
        - firefox
      state: present
    register: force_install_multiple

  - name: assert install multiple packages
    assert:
      that:
      - force_install_multiple is not changed
      - force_install_multiple is not failed

  - name: Force nstall list of software
    chocolatey.chocolatey.win_chocolatey:
      name:
        - 7zip
        - firefox
      state: present
      force: true
      ignore_checksums: true
    register: force_install_multiple

  - name: assert force install multiple packages
    assert:
      that:
      - force_install_multiple is changed
      - force_install_multiple is not failed
...

Operating Systems Testing

N/A

Change Types Made

  • Bug fix (non-breaking change).
  • Feature / Enhancement (non-breaking change).
  • Breaking change (fix or feature that could cause existing functionality to change).
  • Documentation changes.
  • PowerShell code changes.

Change Checklist

  • Requires a change to the documentation.
  • Documentation has been updated.
  • Tests to cover my changes, have been added.
  • All new and existing tests passed?
  • PowerShell code changes: PowerShell v3 compatibility checked?

Related Issue

Fixes #187

Currently, when using the force flag on the win_chocolatey command the
list of packages is being added to the collection of missing packages as
a single string. This results in the packages being passed to choco.exe
bounded by quote character (e.g. `"package1 package2"`) and so this is
being interpreted as a single (incorrect) package name.

This change iterates over the list of packages and adds them individually.

Additionally, tests have been added to cover this failure case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The force: true parameter wraps the package name in quotes braking the install command

1 participant