Workstation setup and creating a CHEF cookbook

Workstation Setup and Writing a cookbook to start the sshd service on Linux endpoint

Harshal Chandile
Sep 7, 2018 · 1 min read

Pre-requisites

  1. Install and Configure chef-server https://docs.chef.io/install_server.html
  2. Download chef-dk https://downloads.chef.io/chefdk
  3. Download Started kit from Chef-server(Chef manage console) and place into your local directory.
  4. Fetch the SSL certificate from your Chef server using
    knife ssl fetch
  5. Validate the SSL certificate from your Chef server
    knife ssl check
  6. Bootstrap a Node(Endpoint)
    https://docs.chef.io/install_bootstrap.html

Now, we will be writing a cookbook to start the sshd service on the Linux endpoint.

Paste the command below from chefdk/powershell(CLI) if the workstation is windows.

chef generate cookbook start_sshd_service

Write below code in default.rb file. (start_sshd_service/recipes/default.rb)

service “sshd” do
action :start
end

Now, Upload your cookbook to the chef server using below command

knife cookbook upload start_sshd_service

Login to the Client Endpoint using putty which is bootstrapped and run the following command.

chef-client -r start_sshd_service

It will start the sshd service on the endpoint!!!!

Congrats !! You have created a cookbook, uploaded to the chef server and executed from endpoint as well!!!

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade