-
Notifications
You must be signed in to change notification settings - Fork 7
:user is required field on some hosts #5
Description
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.