Setting Up Open Source Chef Server , Workstation and Registering a Windows Server 2008 RT With Chef Server

Cloud configuration management has become a vital importance for organizations having lots servers hosted in public as well as private cloud. Cloud configuration management tools really makes it easy to provision and deploy your applications at one place rather than configuring each virtual machines.There are some tools which makes the cloud configuration management so easy and saves you from service outages. One of them is opscode chef.

Opscode Chef:

Chef is a configuration management tool developed by opscode. Chef is written in Erlang and ruby. Chef has a chef server, workstation and a chef client. Chef client will be installed in every node which is added to the chef server. Opscode has a hosted version of chef server, which basically offers free configuration management up to 5 nodes. You can also install a private chef based on your needs. There is also a open source version of chef server.

This tutorial is for chef beginners, who wants to set up chef-server, workstation and the client for testing purposes. Am using EC2 ubuntu 12.04 instances for setting up the open source chef server, workstation and the client for this tutorial.

Setting up Open Source chef server:(version 11.0.8)

1) Launch a ubuntu 12.04 instance and connect the instance using putty or any other ssh clients.

2)update the server using the following command

sudo apt-get update

3)Dowload the chef server package 11.0.8 using the following command

wget https://opscode-omnibus-packages.s3.amazonaws.com/ubuntu/12.04/x86_64/chef-server_11.0.8-1.ubuntu.12.04_amd64.deb

4)Install the package using the root priveleges.

dpkg -i youpackagename.deb

5) Configure the chef server using the following command.

sudo chef-server-ctl reconfigure

6)Check if the chef server is configured using the following command. If your results shows 0 errors , it means chef-server has been configured without any errors.

chef-server-ctl test

7)Now you can access the chef-server web-ui using your instances elastic ip or public dns. Make sure that you open 443 port open in the ec2 security group because you can access the web ui only with https. eg: https://58.32.34.34. 

8)Once the web-ui is loaded you can see the default username and password in the home page itself. login using the default crediantials and you will be prompted to change the default password.

Chef+Server

Somtimes you might get a error when accessing the web-ui saying “502 bad gateway nginx server”. If you get this error just restart the networking or reboot the system and also check if all the services are running.

Setting up workstation:(version: 11.0.6)

Workstation can be any machine. Here am going to use a seperate EC2 ubuntu instance as a workstation. In workstation we configure the cli tool “knife” to upload the cooksbooks created in the workstation. we use git as a version controlling system for workstation.
1)Lunch a EC2 ubuntu instance and connect to it using any ssh client like putty.
Follow this link to set up the workstation: Setting up chef workstation

Registering windows server 2008 RT with chef server:

1)Download and install the chef-client using the msi installer from here. Dowload chef msi installer

2)Set the environment variable for chef client to eun it from anywhere from the command line

 c:opscodechefbin

3)Create a client.rb file inside c:chef and enter the following lines in that file and save it.

log-level :auto
log-location STDOUT
chef_server_url "https://serverfqdn or ip:443"
validation_client_name "chef-validator"

4)Copy the validator file from chef server location /etc/chef-server/chef-validator.pem to c:chefchef-validator.pem

5) Open the hostfile c:windowssystem32driversetc and add the chef server hostname and ip address to the file and save it.

5)Now run the chef-client command in cmd and the windows node will be registered to the chef server with its hostanme. You can confirm it by checking the nodes in chef server web-ui.

Sample Recipe for installing msi packages:

1)Download the chef-handler cookbook from git hub and upload it to the chef-server to handle the exceptions and error for windows recipes.
https://github.com/opscode-cookbooks/chef_handler

knife cookbook upload chef_handler

2)Download the windows cookbook from opscode community and upload it to the chefserver.

Download windows cookbook from here

Recipie:

1)Create a recipe called msiinstall.rb under /cookbooks/windows/recipes/msiinstall.rb
2)Enter the following lines inside the msiinstall.rb file.

windows_package "vagrant" do
source "c:Desktopvagrant.msi"
action :install
end
#vargrant can be any userdefined package name
#source can be any url which has the installer file

3) Upload the cookbook using knife and add the recipe to the windows node run list using the following commands.

Knife cookbook upload windows
knife node run_list add nodename '[cookbook::recipename]#you can also add the recipie to the runlist using web-ui.

4) Run the chef-client command from the windows-server and your package will be installed by fetching the recipe from the chef server.

0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like