From 62d76f50fc1f3af9b9ede458897f1a7cca06097e Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 23 Mar 2017 11:23:02 -0500 Subject: [PATCH] Don't aggregate both name/pkgs and sources in pkg states Doing so will cause problems trying to install as Salt does not support installing from both binary packages and repository packages in the same call to pkg.install. --- salt/states/pkg.py | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/salt/states/pkg.py b/salt/states/pkg.py index 3aa163f06c..fc2d114bdc 100644 --- a/salt/states/pkg.py +++ b/salt/states/pkg.py @@ -2394,6 +2394,7 @@ def mod_aggregate(low, chunks, running): low chunks and merges them into a single pkgs ref in the present low data ''' pkgs = [] + pkg_type = None agg_enabled = [ 'installed', 'latest', @@ -2413,18 +2414,31 @@ def mod_aggregate(low, chunks, running): # Check for the same function if chunk.get('fun') != low.get('fun'): continue - # Pull out the pkg names! - if 'pkgs' in chunk: - pkgs.extend(chunk['pkgs']) - chunk['__agg__'] = True - elif 'name' in chunk: - pkgs.append(chunk['name']) - chunk['__agg__'] = True - if pkgs: - if 'pkgs' in low: - low['pkgs'].extend(pkgs) + # Check first if 'sources' was passed so we don't aggregate pkgs + # and sources together. + if 'sources' in chunk: + if pkg_type is None: + pkg_type = 'sources' + if pkg_type == 'sources': + pkgs.extend(chunk['sources']) + chunk['__agg__'] = True + else: + if pkg_type is None: + pkg_type = 'pkgs' + if pkg_type == 'pkgs': + # Pull out the pkg names! + if 'pkgs' in chunk: + pkgs.extend(chunk['pkgs']) + chunk['__agg__'] = True + elif 'name' in chunk: + pkgs.append(chunk['name']) + chunk['__agg__'] = True + + if pkg_type is not None and pkgs: + if pkg_type in low: + low[pkg_type].extend(pkgs) else: - low['pkgs'] = pkgs + low[pkg_type] = pkgs return low