Merge pull request #12 from netmanagers/master

Allow to specify held packages as a list with no version
This commit is contained in:
N 2018-03-06 22:07:28 +00:00 committed by GitHub
commit 4a404cb6e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 8 deletions

View file

@ -13,3 +13,7 @@ packages formula
- Allow to hold/unhold system packages (#8)
- Add more tests
0.0.4 (2018-03-06)
- Allow to specify held system packages also as a list (#10)

View file

@ -49,10 +49,12 @@ Runs all the other states in the formula.
Allows you to manage system's packages. You can specify:
* ``held``: a dict of `package: version` which will be installed and pinned
to that version using SaltStack's `hold/unhold` capability. When upgrading a
version, the package will be temporarily unheld, upgraded and then held
again.
* ``held``: either a list of packages or a dict of `package: version`,
which will be installed and pinned to the installed version using
SaltStack's `hold/unhold` capability.
When upgrading a version, the package will be temporarily unheld,
upgraded and then held again.
In the RedHat family, helding packages depend on a yum plugin that you
need to install. In order to do this, you can add it using this formula, adding

View file

@ -23,10 +23,14 @@ pkg_req_pkgs:
{% if held_packages != {} %}
held_pkgs:
pkg.installed:
{% if held_packages is mapping %}
- pkgs:
{% for p, v in held_packages.items() %}
- {{ p }}: {{ v }}
{% endfor %}
{% else %}
- pkgs: {{ held_packages }}
{% endif %}
- hold: true
- update_holds: true
- require:

View file

@ -1,8 +1,16 @@
packages:
pkgs:
# A dict of "package: version" pairs:
held:
alien: 8.95
iotop: 0.6-2
# Alternativelly, held packages can also be specified as a list with
# no versions. In this case, the package will be held in the installed
# version.
# held:
# - alien
# - iotop
wanted:
- git
- less

View file

@ -1,8 +1,8 @@
packages:
pkgs:
held:
alien: 8.95
iotop: 0.6-2.el7
- alien
- iotop
wanted:
- git
- less

View file

@ -11,8 +11,10 @@ case os[:name]
when 'redhat', 'centos'
os_packages = %w(yum-plugin-versionlock)
held_packages = {
'alien': '8.95',
'iotop': '0.6-2.el7'
# We use this test for held packages in a list,
# with no version (current version).
'alien': '',
'iotop': ''
}
lock_file = '/etc/yum/pluginconf.d/versionlock.list'
when 'fedora'