package_windows
Manages Windows packages using the first available package manager: Chocolatey, winget, or Scoop.
Parameters
| Parameter | Required | Default | Description |
|---|---|---|---|
package |
Yes | -- | Package name/ID. |
state |
Yes | -- | Desired state: present, absent, or latest. |
States
present-- Ensure the package is installed.absent-- Uninstall the package.latest-- Install if not present, or upgrade if already installed.
Package Manager Detection
The executor auto-detects the available package manager in priority order:
- Chocolatey (
choco.exe) --choco install -y --no-progress - winget (
winget.exe) --winget install --exact --id <name> --silent - Scoop (
scoop.cmd) --scoop install <name>
If none are found, the executor returns an error.
Idempotency
Queries the detected package manager to check if the package is installed and its current version before acting.
Examples
Basic
resources:
- name: Install Git
type: package
package: Git.Git
Ensure latest
resources:
- name: Keep 7-Zip updated
type: package
package: 7zip
state: latest
Uninstall
resources:
- name: Remove old package
type: package
package: legacy-tool
state: absent
Platform
Windows only. On Linux, type: package maps to the package executor (APT/DNF/etc.).
Notes
- Package names depend on the backend. Use Chocolatey package names with
choco, winget IDs withwinget, and Scoop bucket names withscoop. - The executor uses
where.exeto probe for available package managers. - Chocolatey operations include
--no-progressto suppress progress bars. winget operations include--accept-source-agreements --accept-package-agreements.