Workstation setup and creating a CHEF cookbook
Workstation Setup and Writing a cookbook to start the sshd service on Linux endpoint
Sep 7, 2018 · 1 min read
Pre-requisites
- Install and Configure chef-server https://docs.chef.io/install_server.html
- Download chef-dk https://downloads.chef.io/chefdk
- Download Started kit from Chef-server(Chef manage console) and place into your local directory.
- Fetch the SSL certificate from your Chef server using
knife ssl fetch - Validate the SSL certificate from your Chef server
knife ssl check - 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!!!