code: def fetch_file(self, in_path, out_path):
          ''' fetch a file from remote to local '''
          vvv("FETCH %s TO %s" % (in_path, out_path), host=self.host)
          cmd = self._password_cmd()
  
          if C.DEFAULT_SCP_IF_SSH:
              cmd += ["scp"] + self.common_args
              cmd += [self.host + ":" + in_path, out_path]
              indata = None
          else:
              cmd += ["sftp"] + self.common_args + [self.host]
              indata = "get %s %s\n" % (in_path, out_path)
  
          p = subprocess.Popen(cmd, stdin=subprocess.PIPE,
                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
          self._send_password()
          stdout, stderr = p.communicate(indata)
  
          if p.returncode != 0:
              raise errors.AnsibleError("failed to transfer file from %s:\n%s\n%s" % (in_path, stdout, stderr)f fetch_file(self, in_path, out_path):
          ''' fetch a file from remote to local '''
          vvv("FETCH %s TO %s" % (in_path, out_path), host=self.host)
          cmd = self._password_cmd()
  
          if C.DEFAULT_SCP_IF_SSH:
              cmd += ["scp"] + self.common_args
              cmd += [self.host + ":" + in_path, out_path]
              indata = None
          else:
              cmd += ["sftp"] + self.common_args + [self.host]
              indata = "get %s %s\n" % (in_path, out_path)
  
          p = subprocess.Popen(cmd, stdin=subprocess.PIPE,
                               stdout=subprocess.PIPE, stderr=subprocess.PIPE)
          self._send_password()
          stdout, stderr = p.communicate(indata)
  
          if p.returncode != 0:
              raise errors.AnsibleError("failed to transfer file from %s:\n%s\n%s" % (in_path, stdout, stderr))
docs: fetch a file from remote to local