What is Chef?
Chef is a systems and cloud infrastructure automation framework that makes it easy to deploy servers and applications to any physical, virtual, or cloud location, no matter the size of the infrastructure. Each organization is comprised of one (or more) workstations, a single server, and every node that will be configured and maintained by the chef-client. Cookbooks (and recipes) are used to tell the chef-client how each node in your organization should be configured. The chef-client (which is installed on every node) does the actual configuration.
Briefly speaking, there are three major components in chef framework: 1.workstations, 2.chef-server, 3.node (chef-client). The Chef server acts as a hub of information. Cookbooks and policy settings are uploaded to the Chef server by users from workstations. (Policy settings may also be maintained from the Chef server itself, via the Chef management console web user interface.)
Chef management console is the user interface for the Chef server. It is used to manage data bags, attributes, run-lists, roles, environments, and cookbooks, and also to configure role-based access for users and groups.
If you want deploy something to EC2 from your workstations directly and without chef-server, you can refer to this article about how to use Chef-solo to deploy applications and launch an AWS EC2 instance.
In this article, I’d like to show you how to install chef-server, chef management console and workstation on Ubuntu 14.04 step by step. In order to simplify the install procedures, I’ll install these components including chef-server and workstation on the same Ubuntu host.
Use the below command to install it:
$ wget https://packagecloud.io/chef/stable/packages/ubuntu/trusty/chef-server-core_12.3.1-1_amd64.deb $ sudo dpkg -i chef-server-core*
Start all of the services:
$ sudo chef-server-ctl reconfigure
Once the installation is complete, you must call the command, which configures the components that make up the server to work together in your specific environment:
$ sudo chef-server-ctl status
Run the following command to create an administrator:
$ sudo chef-server-ctl user-create USER_NAME FIRST_NAME LAST_NAME EMAIL PASSWORD --filename FILE_NAME
An RSA private key is generated automatically. This is the user’s private key and should be saved to a safe location. The –filename option will save the RSA private key to a specified path.
$ chef-server-ctl user-create stevedanno Steve Danno firstname.lastname@example.org abc123 --filename /path/to/stevedanno.pem
Run the following command to create an organization:
$ chef-server-ctl org-create short_name "full_organization_name" --association_user user_name --filename ORGANIZATION-validator.pem
The name must begin with a lower-case letter or digit, may only contain lower-case letters, digits, hyphens, and underscores, and must be between 1 and 255 characters. For example: 4thcoffee. The full name must begin with a non-white space character and must be between 1 and 1023 characters. For example: “Fourth Coffee, Inc.”. The –association_user option will associate the user_name with the admins security group on the Chef server.
An RSA private key is generated automatically. This is the chef-validator key and should be saved to a safe location. The –filename option will save the RSA private key to a specified path.
$ chef-server-ctl org-create 4thcoffee "Fourth Coffee, Inc." --association_user stevedanno --filename /path/to/4thcoffee-validator.pem
Install chef management console
Download management console:
or you can use command line install it:
$ sudo chef-server-ctl install opscode-manage
Install and configure it:
$ sudo dpkg -i chef-manage_2.1.1-1_amd64.deb $ sudo chef-manage-ctl reconfigure