From 5671ddcdd392c86bd9724b69b11a7dcb81e6c8aa Mon Sep 17 00:00:00 2001 From: Michael Vermaes Date: Thu, 19 Dec 2013 00:40:44 +0800 Subject: [PATCH 1/2] Attempt #2 to cause yum to fail on invalid url --- library/packaging/yum | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/library/packaging/yum b/library/packaging/yum index 4c930f2f77..240f071b9f 100644 --- a/library/packaging/yum +++ b/library/packaging/yum @@ -472,7 +472,11 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos): rc, out, err = module.run_command(cmd) - if (rc != 0 and 'Nothing to do' in err) or 'Nothing to do' in out: + # Fail on invalid urls: + if '://' in spec and 'No package %s available.' % spec in out: + err = 'Package at %s could not be installed' % spec + module.fail_json(changed=False,msg=err,rc=1) + elif (rc != 0 and 'Nothing to do' in err) or 'Nothing to do' in out: # avoid failing in the 'Nothing To Do' case # this may happen with an URL spec. # for an already installed group, From c55d144c509decd291b46445838c0157d84fc59e Mon Sep 17 00:00:00 2001 From: Michael Vermaes Date: Wed, 15 Jan 2014 12:20:31 +0800 Subject: [PATCH 2/2] Fail yum on invalid url with .rpm suffix --- library/packaging/yum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/packaging/yum b/library/packaging/yum index 240f071b9f..b584638639 100644 --- a/library/packaging/yum +++ b/library/packaging/yum @@ -473,7 +473,7 @@ def install(module, items, repoq, yum_basecmd, conf_file, en_repos, dis_repos): rc, out, err = module.run_command(cmd) # Fail on invalid urls: - if '://' in spec and 'No package %s available.' % spec in out: + if (rc == 1 and '://' in spec and ('No package %s available.' % spec in out or 'Cannot open: %s. Skipping.' % spec in err)): err = 'Package at %s could not be installed' % spec module.fail_json(changed=False,msg=err,rc=1) elif (rc != 0 and 'Nothing to do' in err) or 'Nothing to do' in out: