`remote_file` resource fails when specifying `user` attribute different from execution user.
dkam opened this issue · comments
Dan Milne commented
Hi there,
Log:
INFO : Starting Itamae...
INFO : Loading node data from /Users/macuser/Development/deploy/nodes/pg.yml...
INFO : Recipe: /Users/macuser/Development/deploy/cookbooks/app/app_user.rb
ERROR : stdout | chmod: changing permissions of '/tmp/itamae_tmp/1574202178.8791308': Operation not permitted
ERROR : Command `sudo -H -u app_user -- /bin/sh -c cd\ \~app_user\ \;\ chmod\ 0600\ /tmp/itamae_tmp/1574202178.8791308` failed. (exit status: 1)
ERROR : remote_file[/home/app_user/.ssh/authorized_keys] Failed.
remote_file "/home/app_user/.ssh/authorized_keys" do
action :create
user 'app_user'
end
bundle exec itamae ssh --host pg.myapp.info --user root -i ~/.ssh/id_ed25519 cookbooks/app/app_user.rb -y nodes/pg.yml
Might be similar to this issue.
Dan Milne commented
I worked around it like this:
remote_file "/home/app_user/.ssh/authorized_keys" do
action :create
end
file "/home/app_user/.ssh/authorized_keys" do
owner 'app_user'
end