You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I upgrade each package that has an update available witout manually specifying each one
Created From: Notes
bundle agent example_package_updates_installed
{
vars:
debian|ubuntu::
# Get the data about package updates available. packageupdatesmatching()
# returns data (best undersood as a JSON array) about pacakges that have
# updates available based on a cache of information returned from the
# underlying package manager (apt, yum, etc ...)
"packages_with_updates"
# data => packageupdatesmatching( ".*",
# ".*",
# ".*",
# "apt_get");
#
# Here is a mock response
#
data => '
[
{
"arch":"default",
"method":"dpkg",
"name":"syncthing",
"version":"1.1.0~ds1-1"
},
{
"arch":"default",
"method":"dpkg",
"name":"google-chrome-stable",
"version": "79.0.3945.130-1"
}
]';
# We get the index so that we can iterate.
"p" slist => getindices( packages_with_updates );
# Here we define a list of packages that we want to exclude
"excluded_packages"
slist => { "google-chrome-stable" };
# We build a new data structure with just the names of the packages we want to update
"update_candidate_names[$(p)]" string => "$(packages_with_updates[$(p)][name])";
# Finally, we generate a list of the package names we want to update
# excluding any packages we don't want
"updates" slist => difference( getvalues( update_candidate_names ), excluded_packages );
packages:
debian|ubuntu::
#
# Now we promise that each package we want to update is at the latest
# version available (most package modules support this).
#
# "$(updates)"
# version => "latest";
reports:
"I should upgrade $(updates)";
}
bundle agent __main__
{
methods: "example_package_updates_installed";
}