Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permission Denied when uploading solo.rb #91

Open
rickbutton opened this issue Apr 25, 2012 · 7 comments
Open

Permission Denied when uploading solo.rb #91

rickbutton opened this issue Apr 25, 2012 · 7 comments
Labels

Comments

@rickbutton
Copy link

I am testing my chef deployments with vagrant, and started out deploying with the vagrant user. I have tried to abstract away the user from vagrant, and am now trying to use a different user, creating when I bootstrap the box.

When I run fix node:123.123.123.123 using the vagrant user, everything runs perfectly fine, but when I run it using the chef user, (who owns the /etc/chef directory, and can sudo without a password) it fails with the error:

Fatal error: put() encountered an exception while uploading '<StringIO.StringIO instance at 0x10fecc200>'

Underlying exception:
    Permission denied

This exception is thrown around line 94 of solo.py:

upload_template(os.path.join(BASEDIR, 'solo.rb'), '/etc/chef/',
    context=data, use_sudo=True, backup=False, mode=0400)

Why does this happen even though the chef user has the correct permissions?

@tobami
Copy link
Owner

tobami commented Apr 25, 2012

The problem is caused by upload_template having two phases:

  • using put() to upload the file to the user's home directory
  • using sudo to move the file to its final destination dir at /etc/chef

Because you are using the chef user, which doesn't have a home directory, that step is failing. So the solution is to always use "real" system users, that is users which have a home directory.

On LittleChef's side, what we can do is catch that error and output a proper error message, as "Permission denied" is totally useless for a user encountering the problem.

@rickbutton
Copy link
Author

Ah, that makes sense. I don't have the means to test that yet, as my computer blew up about an hour after I opened the issue, but I'll try creating a user with a home and post results when I get a chance.

@rickbutton
Copy link
Author

Tried out creating a new user with a home directory, and it worked perfectly. Thanks!

I would recommend a more descriptive error message like you mentioned.

@tobami
Copy link
Owner

tobami commented Apr 30, 2012

Committed a partial fix (Ugly error still appears), and filed a bug in fabric (fabric/fabric#629), needed to be able to fix it more nicely on our side.

Will leave this open until then

@gondoi
Copy link

gondoi commented Mar 7, 2013

I'm still getting an error here, but not Permissions. I get the following:

$ fix --verbose node:10.14.209.171 deploy_chef
Are you sure you want to install Chef 0.10 at the node 10.14.209.171, using "precise" packages? [Y/n]
Setting up Opscode repository...
Installing Chef Solo

Fatal error: put() encountered an exception while uploading '<StringIO.StringIO instance at 0x108eef950>'

Underlying exception:
    unsupported operand type(s) for &: 'NoneType' and 'int'

Aborting.

Fatal error: Failed to upload '/etc/chef/solo.rb'
This can happen when the deployment user does not have a home directory, which is needed as a temporary location

Aborting.
Disconnecting from 10.14.209.171... done.

I have tried both directly as root and as a real user chef with sudo permissions. I can see that the template file exists in the home directory with a file name of a long hash, but it appears to fail on moving it to /etc/chef/solo.rb

@gondoi
Copy link

gondoi commented Mar 7, 2013

Looks like I overlooked #151

@tobami
Copy link
Owner

tobami commented Mar 8, 2013

Thanks @gondoi , I hope the LittleChef 1.5.0 release today fixes your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants