From 277b8bfaf01f3c5a98a2eebdcf21b29e1a0d0488 Mon Sep 17 00:00:00 2001 From: Dmitriy Khomutov Date: Fri, 18 Aug 2017 12:31:06 -0700 Subject: [PATCH] Alternatives module: Add a check that the path to the executable exist (#24800) * Add check that the path to the executable exists * Corrected a typo --- lib/ansible/modules/system/alternatives.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ansible/modules/system/alternatives.py b/lib/ansible/modules/system/alternatives.py index 36c3ce8b31..3c1df4064f 100644 --- a/lib/ansible/modules/system/alternatives.py +++ b/lib/ansible/modules/system/alternatives.py @@ -68,6 +68,7 @@ EXAMPLES = ''' priority: -10 ''' +import os import re import subprocess @@ -137,6 +138,8 @@ def main(): try: # install the requested path if necessary if path not in all_alternatives: + if not os.path.exists(path): + module.fail_json(msg="Specified path %s does not exist" % path) if not link: module.fail_json(msg="Needed to install the alternative, but unable to do so as we are missing the link")