Run the chef-client as non root user

拈花ヽ惹草 提交于 2019-12-01 08:04:49

问题


I want to run the chef-client as a test user in my linux machine. For that, I add cache path in the client.rb file which is from /etc/chef/client.rb.

cache_path "~/.chef/cache"

Then I run the chef-client command from test user(non-root user).It shows error?

Chef encountered an error attempting to create the client 

How to setup the cache-path? Is is necessary to move the client.rb,chef-validator.pem, client.pem, first-boot.json under test user?


回答1:


First of all, chef is intended to be run as root. A lot of resources assume they're run as root, and need it. They will fail if not running as root.

For your error specifically, your test user has no right to write a file in /etc/chef (default location) and it need to write the client.pem node certificate.

Some ideas:

  1. Give rights on /etc/chef to your test user
  2. use sudo to run chef client with a test user (need an entry in sudoers file)
  3. Modify the client.rb file to point client_key to your test user home directory
  4. Do a first run of chef as root so it can write it's node certificate, then it won't have to write again in /etc/chef


来源:https://stackoverflow.com/questions/28280211/run-the-chef-client-as-non-root-user

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!