Skip to content

Commit

Permalink
Allow the module to handle errors for nonexistent files
Browse files Browse the repository at this point in the history
  • Loading branch information
s-hertel committed May 2, 2018
1 parent 66f5e3f commit dcfd6db
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/ansible/plugins/action/aws_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import os

from ansible.errors import AnsibleError, AnsibleAction, AnsibleActionFail
from ansible.errors import AnsibleError, AnsibleAction, AnsibleActionFail, AnsibleFileNotFound
from ansible.module_utils._text import to_text
from ansible.plugins.action import ActionBase

Expand Down Expand Up @@ -49,6 +49,9 @@ def run(self, tmp=None, task_vars=None):
try:
source = self._loader.get_real_file(self._find_needle('files', source))
new_module_args['src'] = source
except AnsibleFileNotFound as e:
# module handles error message for nonexistent files
new_module_args['src'] = source
except AnsibleError as e:
raise AnsibleActionFail(to_text(e))

Expand Down

0 comments on commit dcfd6db

Please sign in to comment.