First Steps and Permissions Issue

Hi.
Just taking my first steps in Chef, and have given myself a couple of weeks to get to know it. I am using the tutorial here…

https://learn.chef.io/learn-the-basics/rhel/make-your-recipe-more-manageable/

I am running my own chef server on a VM on my Mac. So I get to the bit about the cookbook, and I run…

chef generate cookbook learn_chef_httpd

I get…

[john@chef-server ~]$ chef generate cookbook learn_chef_httpd
chef: Command not found.

I change that command to ‘chef-client’ and it seems to run, but I get…

[john@chef-server ~]$ chef-client generate cookbook learn_chef_httpd
[2016-05-07T18:37:06+01:00] WARN: *****************************************
[2016-05-07T18:37:06+01:00] WARN: Did not find config file: /etc/chef/client.rb, using command line options.
[2016-05-07T18:37:06+01:00] WARN: *****************************************
Starting Chef Client, version 12.9.41
Creating a new client identity for fo-ds-ats.member.g02.yahoodns.net using the validator key.

================================================================================
Chef encountered an error attempting to create the client “fo-ds-ats.member.g02.yahoodns.net

Platform:

x86_64-linux

Running handlers:
[2016-05-07T18:37:08+01:00] ERROR: Running exception handlers
Running handlers complete
[2016-05-07T18:37:08+01:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 01 seconds
[2016-05-07T18:37:08+01:00] FATAL: Stacktrace dumped to /home/john/.chef/cache/chef-stacktrace.out
[2016-05-07T18:37:08+01:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-05-07T18:37:08+01:00] ERROR: I can’t write your private key to /etc/chef/client.pem - check permissions?
[2016-05-07T18:37:08+01:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
[john@chef-server ~]$

I’m lost at this point!

chef is a command that helps you author cookbooks, whereas chef-client is the command to execute recipes on the machine being managed. If you’re not using the provided VM, you will need to install the chefdk.

So what Christine wants to say is that you should install chefdk on your machine in order to be able to run chef commands to be able to use chef generate commands.
Also, chefdk is useful in using knife commands like:
knife cookbook create my_cookbook
knife upload
or
knife search ...

Chefdk will connect you to the chef server via your knife.rb file which should have a content like this:
current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
node_name "workstation1"
client_key "#{current_dir}/workstation1.pem"
validation_client_name "unit-validator"
validation_key "#{current_dir}/team1-validator.pem"
chef_server_url "https://chef-server01.global.corp/organizations/team1"
cookbook_path ["#{current_dir}/../cookbooks"]
cookbook_copyright "yourname"
cookbook_email "your-email@company.com"
#knife[:editor] = "vim"
or

knife[:editor] = "C:\\progra~2\\notepa~1\\notepad++.exe -nosession -multiInst"
encrypted_data_bag_secret "/etc/chef/my_secret_key"

I hope this helps a bit more.

Gabriel