Join with_items for the apt module, yum pending, and various fixes to the yum module to support aliases
This commit is contained in:
parent
86ec639176
commit
25acfa8170
2 changed files with 11 additions and 5 deletions
|
@ -475,6 +475,7 @@ class Runner(object):
|
||||||
inject['hostvars'] = self.setup_cache
|
inject['hostvars'] = self.setup_cache
|
||||||
|
|
||||||
items = self.module_vars.get('items', [])
|
items = self.module_vars.get('items', [])
|
||||||
|
|
||||||
if isinstance(items, basestring) and items.startswith("$"):
|
if isinstance(items, basestring) and items.startswith("$"):
|
||||||
items = items.replace("$","")
|
items = items.replace("$","")
|
||||||
if items in inject:
|
if items in inject:
|
||||||
|
@ -483,6 +484,11 @@ class Runner(object):
|
||||||
raise errors.AnsibleError("unbound variable in with_items: %s" % items)
|
raise errors.AnsibleError("unbound variable in with_items: %s" % items)
|
||||||
if type(items) != list:
|
if type(items) != list:
|
||||||
raise errors.AnsibleError("with_items only takes a list: %s" % items)
|
raise errors.AnsibleError("with_items only takes a list: %s" % items)
|
||||||
|
|
||||||
|
if self.module_name in [ 'apt' ]:
|
||||||
|
# hack for apt and soon yum, with_items maps back into a single module call
|
||||||
|
inject['item'] = ",".join(items)
|
||||||
|
items = []
|
||||||
|
|
||||||
if len(items) == 0:
|
if len(items) == 0:
|
||||||
return self._executor_internal_inner(host, inject, port)
|
return self._executor_internal_inner(host, inject, port)
|
||||||
|
|
10
library/yum
10
library/yum
|
@ -106,7 +106,7 @@ def run_yum(command):
|
||||||
rc = 1
|
rc = 1
|
||||||
err = traceback.format_exc()
|
err = traceback.format_exc()
|
||||||
out = ''
|
out = ''
|
||||||
|
|
||||||
if out is None:
|
if out is None:
|
||||||
out = ''
|
out = ''
|
||||||
if err is None:
|
if err is None:
|
||||||
|
@ -119,7 +119,7 @@ def run_yum(command):
|
||||||
def ensure(my, state, pkgspec):
|
def ensure(my, state, pkgspec):
|
||||||
yumconf = my.conf.config_file_path
|
yumconf = my.conf.config_file_path
|
||||||
res = {}
|
res = {}
|
||||||
if state == 'installed':
|
if state in [ 'installed', 'present' ]:
|
||||||
# check if pkgspec is installed
|
# check if pkgspec is installed
|
||||||
if re.search('[></=]',pkgspec):
|
if re.search('[></=]',pkgspec):
|
||||||
try:
|
try:
|
||||||
|
@ -170,7 +170,7 @@ def ensure(my, state, pkgspec):
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
if state == 'removed':
|
if state in [ 'absent', 'removed' ]:
|
||||||
# check if pkgspec is installed
|
# check if pkgspec is installed
|
||||||
# if not return {changed: False, failed=False }
|
# if not return {changed: False, failed=False }
|
||||||
# if so try to remove it:
|
# if so try to remove it:
|
||||||
|
@ -250,7 +250,7 @@ def ensure(my, state, pkgspec):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# should be caught by AnsibleModule argument_spec
|
# should be caught by AnsibleModule argument_spec
|
||||||
return dict(changed=False, failed=True, results='', errors='unexpected state')
|
return dict(changed=False, failed=True, results='', errors="unexpected state: %s" % state)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ def main():
|
||||||
if params['list'] and params['pkg']:
|
if params['list'] and params['pkg']:
|
||||||
module.fail_json(msg="expected 'list=' or 'name=', but not both")
|
module.fail_json(msg="expected 'list=' or 'name=', but not both")
|
||||||
|
|
||||||
if 'list' in params:
|
if params['list']:
|
||||||
try:
|
try:
|
||||||
my = yum_base(conf_file=params['conf_file'], cachedir=True)
|
my = yum_base(conf_file=params['conf_file'], cachedir=True)
|
||||||
results = dict(results=list_stuff(my, params['list']))
|
results = dict(results=list_stuff(my, params['list']))
|
||||||
|
|
Loading…
Reference in a new issue