mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* Change all packages at once in yum_versionlock module * Re-enable tests * Convert package list to packages string * Fix module * Change variable name to make it appropriate * Fix module check_mode * Revert "Fix module" and apply felixfontein suggestion This reverts commit5936da3198
. * Rename package to packages * Only change packages which are needed * Ignore if list is empty * Add changelog (cherry picked from commit811b609b05
) Co-authored-by: Amin Vakil <info@aminvakil.com>
This commit is contained in:
parent
83c6d18bc0
commit
196e8fe4e3
3 changed files with 14 additions and 7 deletions
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
minor_changes:
|
||||
- yum_versionlock - Do the lock/unlock concurrently to speed up (https://github.com/ansible-collections/community.general/pull/1912).
|
|
@ -13,7 +13,7 @@ module: yum_versionlock
|
|||
version_added: 2.0.0
|
||||
short_description: Locks / unlocks a installed package(s) from being updated by yum package manager
|
||||
description:
|
||||
- This module adds installed packages to yum versionlock to prevent the package from being updated.
|
||||
- This module adds installed packages to yum versionlock to prevent the package(s) from being updated.
|
||||
options:
|
||||
name:
|
||||
description:
|
||||
|
@ -93,9 +93,9 @@ class YumVersionLock:
|
|||
self.module.fail_json(msg="Error: Please install rpm package yum-plugin-versionlock : " + to_native(err) + to_native(out))
|
||||
self.module.fail_json(msg="Error: " + to_native(err) + to_native(out))
|
||||
|
||||
def ensure_state(self, package, command):
|
||||
""" Ensure package state """
|
||||
rc, out, err = self.module.run_command([self.yum_bin, "-q", "versionlock", command, package])
|
||||
def ensure_state(self, packages, command):
|
||||
""" Ensure packages state """
|
||||
rc, out, err = self.module.run_command([self.yum_bin, "-q", "versionlock", command] + packages)
|
||||
if rc == 0:
|
||||
return True
|
||||
self.module.fail_json(msg="Error: " + to_native(err) + to_native(out))
|
||||
|
@ -121,6 +121,7 @@ def main():
|
|||
versionlock_packages = yum_v.get_versionlock_packages()
|
||||
|
||||
# Ensure versionlock state of packages
|
||||
packages_list = []
|
||||
if state in ('present'):
|
||||
command = 'add'
|
||||
for single_pkg in packages:
|
||||
|
@ -128,7 +129,9 @@ def main():
|
|||
if module.check_mode:
|
||||
changed = True
|
||||
continue
|
||||
changed = yum_v.ensure_state(single_pkg, command)
|
||||
packages_list.append(single_pkg)
|
||||
if packages_list:
|
||||
changed = yum_v.ensure_state(packages_list, command)
|
||||
elif state in ('absent'):
|
||||
command = 'delete'
|
||||
for single_pkg in packages:
|
||||
|
@ -136,7 +139,9 @@ def main():
|
|||
if module.check_mode:
|
||||
changed = True
|
||||
continue
|
||||
changed = yum_v.ensure_state(single_pkg, command)
|
||||
packages_list.append(single_pkg)
|
||||
if packages_list:
|
||||
changed = yum_v.ensure_state(packages_list, command)
|
||||
|
||||
module.exit_json(
|
||||
changed=changed,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
disabled # The tests are way too slow - the locking/unlocking steps need 10 minutes each!
|
||||
shippable/posix/group1
|
||||
skip/aix
|
||||
skip/freebsd
|
||||
|
|
Loading…
Reference in a new issue