mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* zypper: support transactional-updates
- Check if transactional updates are in use by checking for the
existence of /var/lib/misc/transactional-update.state
- Prefix zypper-commands with /sbin/transactional-update --continue --drop-if-no-change --quiet run
if this is the case
fixes ansible-collections/community.general#3159
* re-add get_bin_path for executables
* fix typo
(cherry picked from commit 6033ce695b
)
Co-authored-by: Sebastian <sebix@sebix.at>
This commit is contained in:
parent
d71c10da27
commit
0eecd48ea8
2 changed files with 10 additions and 0 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- zypper - prefix zypper commands with ``/sbin/transactional-update --continue --drop-if-no-change --quiet run`` if transactional updates are detected (https://github.com/ansible-collections/community.general/issues/3159).
|
|
@ -29,6 +29,7 @@ author:
|
||||||
short_description: Manage packages on SUSE and openSUSE
|
short_description: Manage packages on SUSE and openSUSE
|
||||||
description:
|
description:
|
||||||
- Manage packages on SUSE and openSUSE using the zypper and rpm tools.
|
- Manage packages on SUSE and openSUSE using the zypper and rpm tools.
|
||||||
|
- Also supports transactional updates, by running zypper inside C(/sbin/transactional-update --continue --drop-if-no-change --quiet run).
|
||||||
options:
|
options:
|
||||||
name:
|
name:
|
||||||
description:
|
description:
|
||||||
|
@ -213,6 +214,7 @@ EXAMPLES = '''
|
||||||
ZYPP_LOCK_TIMEOUT: 20
|
ZYPP_LOCK_TIMEOUT: 20
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
import os.path
|
||||||
import xml
|
import xml
|
||||||
import re
|
import re
|
||||||
from xml.dom.minidom import parseString as parseXML
|
from xml.dom.minidom import parseString as parseXML
|
||||||
|
@ -337,6 +339,8 @@ def get_cmd(m, subcommand):
|
||||||
is_install = subcommand in ['install', 'update', 'patch', 'dist-upgrade']
|
is_install = subcommand in ['install', 'update', 'patch', 'dist-upgrade']
|
||||||
is_refresh = subcommand == 'refresh'
|
is_refresh = subcommand == 'refresh'
|
||||||
cmd = [m.get_bin_path('zypper', required=True), '--quiet', '--non-interactive', '--xmlout']
|
cmd = [m.get_bin_path('zypper', required=True), '--quiet', '--non-interactive', '--xmlout']
|
||||||
|
if transactional_updates():
|
||||||
|
cmd = [m.get_bin_path('transactional-update', required=True), '--continue', '--drop-if-no-change', '--quiet', 'run'] + cmd
|
||||||
if m.params['extra_args_precommand']:
|
if m.params['extra_args_precommand']:
|
||||||
args_list = m.params['extra_args_precommand'].split()
|
args_list = m.params['extra_args_precommand'].split()
|
||||||
cmd.extend(args_list)
|
cmd.extend(args_list)
|
||||||
|
@ -491,6 +495,10 @@ def repo_refresh(m):
|
||||||
|
|
||||||
return retvals
|
return retvals
|
||||||
|
|
||||||
|
|
||||||
|
def transactional_updates():
|
||||||
|
return os.path.exists('/var/lib/misc/transactional-update.state')
|
||||||
|
|
||||||
# ===========================================
|
# ===========================================
|
||||||
# Main control flow
|
# Main control flow
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue