问题
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:
- Give rights on
/etc/chef
to your test user - use
sudo
to run chef client with a test user (need an entry in sudoers file) - Modify the
client.rb
file to pointclient_key
to your test user home directory - 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