summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarkos Chandras <hwoarang@users.noreply.github.com>2018-03-09 08:28:36 +0000
committeransibot <ansibot@users.noreply.github.com>2018-03-09 03:28:36 -0500
commit5234b78b5f5a911f710565f2596ff3edb59b2665 (patch)
treec979ac2423eedee896938b80bd878ec3c342ea8d /lib
parent74e79d9f5e3da3767f8d32a6fac7a047439d1e8f (diff)
downloadansible-5234b78b5f5a911f710565f2596ff3edb59b2665.tar.gz
modules: zypper: Optimize the 'search' subcommand (#37191)
When looking for installed packages we do not need to query repositories since we only care about the rpmdb. As such, we can disable all the repositories operations in order to improve the performance of that step Before this patch, when using 'state: present' in the zypper module, the operation was taking about 12 seconds to complete: time ansible-playbook foo.yml 1>/dev/null real 0m12.614s user 0m10.880s sys 0m0.683s After this patch: time ansible-playbook foo.yml 1>/dev/null real 0m4.193s user 0m2.560s sys 0m0.575s see: https://bugzilla.opensuse.org/show_bug.cgi?id=1084525
Diffstat (limited to 'lib')
-rw-r--r--lib/ansible/modules/packaging/os/zypper.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/ansible/modules/packaging/os/zypper.py b/lib/ansible/modules/packaging/os/zypper.py
index 15281e0bce..b998596067 100644
--- a/lib/ansible/modules/packaging/os/zypper.py
+++ b/lib/ansible/modules/packaging/os/zypper.py
@@ -313,6 +313,9 @@ def get_cmd(m, subcommand):
if (is_install or is_refresh) and m.params['disable_gpg_check']:
cmd.append('--no-gpg-checks')
+ if subcommand == 'search':
+ cmd.append('--disable-repositories')
+
cmd.append(subcommand)
if subcommand not in ['patch', 'dist-upgrade'] and not is_refresh:
cmd.extend(['--type', m.params['type']])