アクセス許可が拒否された場合の解決方法 @ rb_sysopen

概要

ファイルを作成するための簡単なレシピを書いています。

file '/myfile' do
  content 'Welcome to Technical Guftgu'
  action :create
end

しかし、chef-client -zr “recipe[test::recipe1]” では次のエラーが発生します。

[2022-03-08T10:54:16+00:00] ERROR: Running exception handlers
Running handlers complete
[2022-03-08T10:54:16+00:00] ERROR: Exception handlers complete
Chef Infra Client failed. 0 resources updated in 02 seconds
[2022-03-08T10:54:16+00:00] FATAL: Stacktrace dumped to /home/vagrant/.chef/local-mode-cache/cache/chef-stacktrace.out
[2022-03-08T10:54:16+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2022-03-08T10:54:16+00:00] FATAL: Errno::EACCES: file[/myfile] (test::recipe1 line 7) had an error: Errno::EACCES: Permission denied @ rb_sysopen - /myfile

解決策

あなたのアプリはファイル /myfile にアクセスできないようです。

すべてへのアクセスを許可するには、これを試してください: sudo chmod a+rw /myfile