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
This commit is contained in:
Dmitriy Khomutov 2017-08-18 12:31:06 -07:00 committed by ansibot
parent fd01a9bb99
commit 277b8bfaf0

View file

@ -68,6 +68,7 @@ EXAMPLES = '''
priority: -10 priority: -10
''' '''
import os
import re import re
import subprocess import subprocess
@ -137,6 +138,8 @@ def main():
try: try:
# install the requested path if necessary # install the requested path if necessary
if path not in all_alternatives: 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: if not link:
module.fail_json(msg="Needed to install the alternative, but unable to do so as we are missing the link") module.fail_json(msg="Needed to install the alternative, but unable to do so as we are missing the link")