itamae-kitchen / itamae

Configuration management tool inspired by Chef, but simpler and lightweight. Formerly known as Lightchef.

Home Page:https://itamae.kitchen/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`remote_file` resource fails when specifying `user` attribute different from execution user.

dkam opened this issue · comments

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.

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