arista-eosplus / packer-ztpserver

Packer.io set up of ZTP server
18 stars 9 forks source link

"create-ztpserver.py virtualbox eos" fails because permission errors on OS X #7

Closed advornic closed 9 years ago

advornic commented 9 years ago
Something else went wrong
Traceback (most recent call last):
  File "./create-ztpserver.py", line 580, in <module>
    main()
  File "./create-ztpserver.py", line 555, in main
    installPacker(hostOS, hostArch)
  File "./create-ztpserver.py", line 96, in installPacker
    subprocess.call(["packer", "-v"])
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
    return Popen(*popenargs, **kwargs).wait()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 709, in __init__
    errread, errwrite)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1326, in _execute_child
    raise child_exception
OSError: [Errno 13] Permission denied

This seems to be because:

# ls -l /Users/<USERNAME>/packer-bin/packer
-rw-r--r--  1 advornic  staff  10056812 Jan 20 02:34 /Users/advornic/packer-bin/packer

(note file is not executable)

Workaround is to manually do:

sudo chmod 777 /Users/<USERNAME>/packer-bin/*

and then execute the command again.

phil-dileo commented 9 years ago

I wonder why I didn't run into this during testing. I guess it wouldn't be tough to chmod the files after download.

phil-dileo commented 9 years ago

Not sure if this is a local preference, but when I download the Packer zip and and extract it the files are executable by default. Regardless, I added a bit of code to set the files to be executable.

for file in os.listdir(packerDir):
        file = os.path.join(packerDir, file)
        os.chmod(file, 0o777)