Skip to content

ansible-pull failed with permission denied #21

Description

@tftm

Hi!
For ansible portable version 0.5 for python 3 when I run ansibe-pull like:
/usr/bin/python /opt/ent/bin/ansiblePortable/py3/ansible-pull --url https://git_repo --inventory /path_to_inv.py
i get error:
Traceback (most recent call last):
File "/opt/bin/ansiblePortable/py3/ansible-pull/main.py", line 139, in
exit_code = cli.run()
File "/opt/bin/ansiblePortable/py3/ansible/ansible/cli/pull.py", line 241, in run
rc, b_out, b_err = run_cmd(cmd, live=True)
File "/opt/bin/ansiblePortable/py3/ansible/ansible/utils/cmd_functions.py", line 44, in run_cmd
p = subprocess.Popen(cmdargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
File "/usr/lib64/python3.8/subprocess.py", line 854, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib64/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
PermissionError: [Errno 13] Permission denied: b'/opt/bin/ansiblePortable/py3/ansible'

I can fix it by adding "cmd = 'python ' + cmd" string in def_run function in ansible/utils/cmd_functions.py like

def run_cmd(cmd, live=False, readsize=10):

    # readsize = 10
    cmd = 'python ' + cmd                                     # <<< THIS STRING
    # On python2, shlex needs byte strings
    if PY2:
         cmd = to_bytes(cmd, errors='surrogate_or_strict')
    cmdargs = shlex.split(cmd)
 
    # subprocess should be passed byte strings.  (on python2.6 it must be
    # passed byte strtings)
    cmdargs = [to_bytes(a, errors='surrogate_or_strict') for a in cmdargs]
 
    p = subprocess.Popen(cmdargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

but I think it's need to fix by more proper way.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions