How to setup a Chef Server in Hosted Environment

How to setup a Chef Server in Hosted Environment

chef_server_hosted_environment_setup

Here in this article we will setup Workstation where Chef recipes and cookbooks can be prepared and manage them using Hosted chef server.

Test Environment

Fedora Server

Procedure

Step1: Sign-up for Hosted chef

As a first step sign up for the Hosted chef and proivde the required details for the same.

URL - https://manage.chef.io/signup/

Step2: Login to Chef management console

Once the sign up is successfull, you can login to the Hosted chef management console.

URL - https://manage.chef.io/login

Step3: Create a New Organization

In this step we need to create a new organization by providing the required details.

  • GoTo – Organizations – Create
  • Provide – Full Name and Short Name

Step4: Setup .chef directory

Here we are going to setup our workstation to communicate with the Hosted Chef server, which was setup in step 2.

About Knife, command line utility
This tool is used  as an interface between workstation and Chef server
This tool is used for uploading the cookbooks to chef server and work with nodes
This tool requires two files to authentication with chef server
RSA private key of the chef user
Knife.rb configuration file downloaded from chef server

Generate knife configuration file
Sign in to https://manage.chef.io/login.
From the Administration tab, select your organization.
From the menu on the left, select Generate Knife Config and save the file content to knife.rb below.
[root@desktop1 chefspace]# pwd
/home/student/Middleware/Source/chefspace
[root@desktop1 chefspace]# mkdir .chef
[root@desktop1 chefspace]# cd .chef/
[root@desktop1 .chef]# vi knife.rb
Generate RSA private key
Sign in to https://manage.chef.io/.
From the Administration tab, select Users from the menu on the left.
Select your user name, select Reset key from the menu on the left, download the RSA private key and save the content to <username>.pem file.
[root@desktop1 chefspace]# pwd
/home/student/Middleware/Source/chefspace
[root@desktop1 chefspace]# mkdir .chef
[root@desktop1 chefspace]# cd .chef/
[root@desktop1 .chef]# vi <username>.pem
[root@desktop1 .chef]# ls -ltr
total 8
-rw-r--r--. 1 root root  427 Jun  5 00:56 knife.rb
-rw-r--r--. 1 root root 1679 Jun  5 00:58 <username>.pem
[root@desktop1 .chef]# knife ssl check
Connecting to host api.chef.io:443
Successfully verified certificates from `api.chef.io'

At this point, our workstation is setup and communicating with the Hosted Chef server.

Step5: Get the learn_chef_httpd cookbook from github

Let’s download a sample Chef cookbook from GitHub repository as shown below.

[root@desktop1 chefspace]# mkdir cookbooks
[root@desktop1 chefspace]# cd cookbooks/
[root@desktop1 cookbooks]# git clone https://github.com/learn-chef/learn_chef_httpd.git
Cloning into 'learn_chef_httpd'...
remote: Counting objects: 93, done.
remote: Total 93 (delta 0), reused 0 (delta 0), pack-reused 93
Unpacking objects: 100% (93/93), done.

Step6: Upload the cookbook to chef hosted server

Now let’s try to upload a cookbook to the hosted chef server environment.

[root@desktop1 cookbooks]# knife cookbook upload learn_chef_httpd
Uploading learn_chef_httpd [0.1.0]
Uploaded 1 cookbook.

Step7: List cookbooks present on chef hosted server

Now we will use the knife utility to list the cookbooks from our environment.

[root@desktop1 cookbooks]# knife cookbook list
learn_chef_httpd   0.1.0

Hope you enjoyed reading this article. Thank you..