Skip to content
This repository has been archived by the owner on May 14, 2021. It is now read-only.

:user is required field on some hosts #5

Open
plainlystated opened this issue Mar 25, 2016 · 0 comments
Open

:user is required field on some hosts #5

plainlystated opened this issue Mar 25, 2016 · 0 comments

Comments

@plainlystated
Copy link

For some reason, on a subset of my (essentially identical) hosts, chef fails unless I explicitly provide a :user to the git block:

#<ArgumentError: couldn't find HOME environment -- expanding `~'> had an error:
couldn't find HOME environment -- expanding `~'

It's fine when I run the client manually (sudo chef-client), but the automated runs fail.

The top of the stacktrace:

var/chef/cache/cookbooks/application_git/files/halite_gem/poise_application_git/resource.rb:87:in `expand_path'
/var/chef/cache/cookbooks/application_git/files/halite_gem/poise_application_git/resource.rb:87:in `ssh_wrapper_path'
/var/chef/cache/cookbooks/application_git/files/halite_gem/poise_application_git/resource.rb:75:in `deploy_key'
/var/chef/cache/cookbooks/workbench/recipes/app.rb:89:in `block (2 levels) in from_file'

Where line 89 in my app.rb is:

 83 application node['workbench']['app']['home'] do                                                                                                                                                                 
 84   owner 'workbench'                                                                                                                                                                                             
 85   group 'workbench'                                                                                                                                                                                             
 86                                                                                                                                                                                                                 
 87   git do                                                                                                                                                                                                        
 88     repository node['workbench']['app']['repo']                                                                                                                                                                 
 89     deploy_key '/etc/id_rsa-workbench_deploy'                                                                                                                                                                   
 90     revision node['workbench']['app']['repo_revision']                                                                                                                                                          
 91   end                                                                                                                                                                                                           
 92 end

...and it fails in ssh_wrapper_path from this codebase:

    def ssh_wrapper_path
      @ssh_wrapper_path ||= ::File.expand_path("~#{user}/.ssh/ssh_wrapper_#{Zlib.crc32(name)}")
    end

If I add user 'root' to the git block, it works. (The id_rsa file is only readable by root), though it only works if the user declaration is above the deploy_key declaration.

The strange thing about this is that it only fails on a subset of my hosts.

Now that I've figured out that adding the user fixed it, I'm fine. Leaving this issue here in case anyone is searching for a solution later, or in case ya'll think a docs update is warranted.

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

No branches or pull requests

1 participant