|
|
@ -20,7 +20,7 @@ __metaclass__ = type
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
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.module_utils._text import to_text
|
|
|
|
from ansible.plugins.action import ActionBase
|
|
|
|
from ansible.plugins.action import ActionBase
|
|
|
|
|
|
|
|
|
|
|
@ -43,9 +43,15 @@ class ActionModule(ActionBase):
|
|
|
|
new_module_args = self._task.args.copy()
|
|
|
|
new_module_args = self._task.args.copy()
|
|
|
|
if source:
|
|
|
|
if source:
|
|
|
|
source = os.path.expanduser(source)
|
|
|
|
source = os.path.expanduser(source)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# For backward compatibility check if the file exists on the remote; it should take precedence
|
|
|
|
|
|
|
|
if not self._remote_file_exists(source):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
source = self._loader.get_real_file(self._find_needle('files', source))
|
|
|
|
source = self._loader.get_real_file(self._find_needle('files', source))
|
|
|
|
new_module_args['src'] = 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:
|
|
|
|
except AnsibleError as e:
|
|
|
|
raise AnsibleActionFail(to_text(e))
|
|
|
|
raise AnsibleActionFail(to_text(e))
|
|
|
|
|
|
|
|
|
|
|
|