Packages
Enumerates all installed system packages and their versions.
Trait Path
packages
Fields
| Path | Type | Example | Description |
|---|---|---|---|
packages.installed |
object | {"bash": "5.1-6", "curl": "7.81.0-1"} |
Map of package name to installed version |
Collection Method
Tries package managers in order of priority:
- dpkg (Debian/Ubuntu) -- runs
dpkg-query -W -f '${Package}\t${Version}\n' - rpm (RHEL/Fedora/SUSE) -- runs
rpm -qa --queryformat '%{NAME}\t%{VERSION}-%{RELEASE}\n' - brew (macOS) -- runs
brew list --versions
Returns an empty object if no supported package manager is found.
Using in When Expressions
- name: configure-nginx
type: file
target_path: /etc/nginx/nginx.conf
when: "os_family('debian')"
Using in Templates
- name: package-report
type: file
target_path: /var/lib/vigo/package-report.txt
content: |
Installed packages on {{ .Traits.network.hostname }}:
{{ range $name, $ver := .Traits.packages.installed }}{{ $name }}={{ $ver }}
{{ end }}