mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
pkgin: add stdout to error message when shell commands fail
This commit is contained in:
parent
e9ca960558
commit
b2aed1a4ba
1 changed files with 5 additions and 5 deletions
|
@ -63,7 +63,7 @@ def query_package(module, name, state="installed"):
|
|||
|
||||
if state == "installed":
|
||||
|
||||
(rc, stdout, stderr) = module.run_command("%s list | grep ^%s" % (PKGIN_PATH, name))
|
||||
rc, out, err = module.run_command("%s list | grep ^%s" % (PKGIN_PATH, name))
|
||||
|
||||
if rc == 0:
|
||||
return True
|
||||
|
@ -80,10 +80,10 @@ def remove_packages(module, packages):
|
|||
if not query_package(module, package):
|
||||
continue
|
||||
|
||||
module.run_command("%s -y remove %s" % (PKGIN_PATH, package))
|
||||
rc, out, err = module.run_command("%s -y remove %s" % (PKGIN_PATH, package))
|
||||
|
||||
if query_package(module, package):
|
||||
module.fail_json(msg="failed to remove %s" % (package))
|
||||
module.fail_json(msg="failed to remove %s: %s" % (package, out))
|
||||
|
||||
remove_c += 1
|
||||
|
||||
|
@ -102,10 +102,10 @@ def install_packages(module, packages):
|
|||
if query_package(module, package):
|
||||
continue
|
||||
|
||||
module.run_command("%s -y install %s" % (PKGIN_PATH, package))
|
||||
rc, out, err = module.run_command("%s -y install %s" % (PKGIN_PATH, package))
|
||||
|
||||
if not query_package(module, package):
|
||||
module.fail_json(msg="failed to install %s" % (package))
|
||||
module.fail_json(msg="failed to install %s: %s" % (package, out))
|
||||
|
||||
install_c += 1
|
||||
|
||||
|
|
Loading…
Reference in a new issue