prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Support scripts dir in roles
  Could we extend roles to support scripts?
  
  So 
  
  ```
  - script: myscript.sh
  ```
  
  Gets automagically sucked up from, roles/myrole/scripts/myscript.sh
  
  ?
  
  
  </issue>
  <code>
  [start of lib/ansible/runner/action_plugins/script.py]
  1 # (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
  2 #
  3 # This file is part of Ansible
  4 #
  5 # Ansible is free software: you can redistribute it and/or modify
  6 # it under the terms of the GNU General Public License as published by
  7 # the Free Software Foundation, either version 3 of the License, or
  8 # (at your option) any later version.
  9 #
  10 # Ansible is distributed in the hope that it will be useful,
  11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13 # GNU General Public License for more details.
  14 #
  15 # You should have received a copy of the GNU General Public License
  16 # along with Ansible.  If not, see <http://www.gnu.org/licenses/>.
  17 
  18 import os
  19 import shlex
  20 
  21 import ansible.constants as C
  22 from ansible.utils import template
  23 from ansible import utils
  24 from ansible import errors
  25 from ansible.runner.return_data import ReturnData
  26 
  27 class ActionModule(object):
  28 
  29     def __init__(self, runner):
  30         self.runner = runner
  31 
  32     def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **kwargs):
  33         ''' handler for file transfer operations '''
  34 
  35         if self.runner.check:
  36             # in check mode, always skip this module
  37             return ReturnData(conn=conn, comm_ok=True, result=dict(skipped=True, msg='check mode not supported for this module'))
  38 
  39         tokens  = shlex.split(module_args)
  40         source  = tokens[0]
  41         # FIXME: error handling
  42         args    = " ".join(tokens[1:])
  43         source  = template.template(self.runner.basedir, source, inject)
  44         source  = utils.path_dwim(self.runner.basedir, source)
  45 
  46         # transfer the file to a remote tmp location
  47         source  = source.replace('\x00','') # why does this happen here?
  48         args    = args.replace('\x00','') # why does this happen here?
  49         tmp_src = os.path.join(tmp, os.path.basename(source))
  50         tmp_src = tmp_src.replace('\x00', '') 
  51 
  52         conn.put_file(source, tmp_src)
  53 
  54         # fix file permissions when the copy is done as a different user
  55         if self.runner.sudo and self.runner.sudo_user != 'root':
  56             prepcmd = 'chmod a+rx %s' % tmp_src
  57         else:
  58             prepcmd = 'chmod +x %s' % tmp_src
  59 
  60         # add preparation steps to one ssh roundtrip executing the script
  61         module_args = prepcmd + '; ' + tmp_src + ' ' + args
  62 
  63         handler = utils.plugins.action_loader.get('raw', self.runner)
  64         result = handler.run(conn, tmp, 'raw', module_args, inject)
  65 
  66         # clean up after
  67         if tmp.find("tmp") != -1 and C.DEFAULT_KEEP_REMOTE_FILES != '1':
  68             self.runner._low_level_exec_command(conn, 'rm -rf %s >/dev/null 2>&1' % tmp, tmp)
  69 
  70         return result
  71
  [end of lib/ansible/runner/action_plugins/script.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/lib/ansible/runner/action_plugins/script.py b/lib/ansible/runner/action_plugins/script.py
  --- a/lib/ansible/runner/action_plugins/script.py
  +++ b/lib/ansible/runner/action_plugins/script.py
  @@ -41,7 +41,10 @@
           # FIXME: error handling
           args    = " ".join(tokens[1:])
           source  = template.template(self.runner.basedir, source, inject)
  -        source  = utils.path_dwim(self.runner.basedir, source)
  +        if '_original_file' in inject:
  +            source = utils.path_dwim_relative(inject['_original_file'], 'files', source, self.runner.basedir)
  +        else:
  +            source = utils.path_dwim(self.runner.basedir, source)
   
           # transfer the file to a remote tmp location
           source  = source.replace('\x00','') # why does this happen here?
  
verification_info: {"golden_diff": "diff --git a/lib/ansible/runner/action_plugins/script.py b/lib/ansible/runner/action_plugins/script.py\n--- a/lib/ansible/runner/action_plugins/script.py\n+++ b/lib/ansible/runner/action_plugins/script.py\n@@ -41,7 +41,10 @@\n         # FIXME: error handling\n         args    = \" \".join(tokens[1:])\n         source  = template.template(self.runner.basedir, source, inject)\n-        source  = utils.path_dwim(self.runner.basedir, source)\n+        if '_original_file' in inject:\n+            source = utils.path_dwim_relative(inject['_original_file'], 'files', source, self.runner.basedir)\n+        else:\n+            source = utils.path_dwim(self.runner.basedir, source)\n \n         # transfer the file to a remote tmp location\n         source  = source.replace('\\x00','') # why does this happen here?\n", "issue": "Support scripts dir in roles\nCould we extend roles to support scripts?\n\nSo \n\n```\n- script: myscript.sh\n```\n\nGets automagically sucked up from, roles/myrole/scripts/myscript.sh\n\n?\n\n", "before_files": [{"content": "# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>\n#\n# This file is part of Ansible\n#\n# Ansible is free software: you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# Ansible is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with Ansible.  If not, see <http://www.gnu.org/licenses/>.\n\nimport os\nimport shlex\n\nimport ansible.constants as C\nfrom ansible.utils import template\nfrom ansible import utils\nfrom ansible import errors\nfrom ansible.runner.return_data import ReturnData\n\nclass ActionModule(object):\n\n    def __init__(self, runner):\n        self.runner = runner\n\n    def run(self, conn, tmp, module_name, module_args, inject, complex_args=None, **kwargs):\n        ''' handler for file transfer operations '''\n\n        if self.runner.check:\n            # in check mode, always skip this module\n            return ReturnData(conn=conn, comm_ok=True, result=dict(skipped=True, msg='check mode not supported for this module'))\n\n        tokens  = shlex.split(module_args)\n        source  = tokens[0]\n        # FIXME: error handling\n        args    = \" \".join(tokens[1:])\n        source  = template.template(self.runner.basedir, source, inject)\n        source  = utils.path_dwim(self.runner.basedir, source)\n\n        # transfer the file to a remote tmp location\n        source  = source.replace('\\x00','') # why does this happen here?\n        args    = args.replace('\\x00','') # why does this happen here?\n        tmp_src = os.path.join(tmp, os.path.basename(source))\n        tmp_src = tmp_src.replace('\\x00', '') \n\n        conn.put_file(source, tmp_src)\n\n        # fix file permissions when the copy is done as a different user\n        if self.runner.sudo and self.runner.sudo_user != 'root':\n            prepcmd = 'chmod a+rx %s' % tmp_src\n        else:\n            prepcmd = 'chmod +x %s' % tmp_src\n\n        # add preparation steps to one ssh roundtrip executing the script\n        module_args = prepcmd + '; ' + tmp_src + ' ' + args\n\n        handler = utils.plugins.action_loader.get('raw', self.runner)\n        result = handler.run(conn, tmp, 'raw', module_args, inject)\n\n        # clean up after\n        if tmp.find(\"tmp\") != -1 and C.DEFAULT_KEEP_REMOTE_FILES != '1':\n            self.runner._low_level_exec_command(conn, 'rm -rf %s >/dev/null 2>&1' % tmp, tmp)\n\n        return result\n", "path": "lib/ansible/runner/action_plugins/script.py"}]}