Chef infrastructure setup

From Notes_Wiki
Revision as of 05:43, 14 December 2014 by Saurabh (talk | contribs) (Created page with "<yambe:breadcrumb>Chef|Chef</yambe:breadcrumb> =Chef infrastructure setup= ==Install Chef server== In case of a virtual server (such as openVZ container) 2.5GB RAM, 500k ino...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<yambe:breadcrumb>Chef|Chef</yambe:breadcrumb>

Chef infrastructure setup

Install Chef server

In case of a virtual server (such as openVZ container) 2.5GB RAM, 500k inodes and 10GB disk space is recommended

  1. yum -y install postgresql
  2. Download chef server from http://downloads.chef.io/chef-server/
  3. rpm -ivh *.rpm
  4. chef-server-ctl reconfigure
  5. Download ops-manage from http://downloads.getchef.com/chef-manage/ to /root
  6. chef-server-ctl install opscode-manage --path /root
  7. opscode-manage-ctl reconfigure
  8. chef-server-ctl reconfigure
  9. chef-server-ctl user-create saurabh Saurabh Barjatiya saurabh@rekallsoftware.com iiit123 --filename saurabh.pem
  10. Open http://<server-IP>/ and login using username (saurabh) and password (iiit123)
  11. Create organization and download starter kit. It will warn about regenerating keys. That is ok.
  12. Other way to create organization is:
    chef-server-ctl org-create rekall Rekall Software Pvt. Ltd. --association_user saurabh --filename rekall.pem
  13. Save starter-kit on a workstation and use it to work with server

Steps learned from https://docs.chef.io/install_server.html


Configure chef-server and knife workstation combination using command line

  1. On chef server create a new user using:
    chef-server-ctl user-create user_name first_name last_name email password --filename FILE_NAME
    chef-server-ctl user-create saurabh Saurabh Barjatiya saurabh@rekallsoftware.com iiit123 --filename saurabh.pem
  2. Then create a new organization using:
    chef-server-ctl org-create short_name full_organization_name --association_user user_name --filename FILE_NAME
    Example
    chef-server-ctl org-create rekall Rekall Software Pvt. Ltd. --association_user saurabh --filename rekall.pem
  3. Install chef development kit on client as explained at chef-apply and receipe syntax
  4. Verify using chef-client -v that client got installed properly
  5. Create ~/.chef and copy the two user and organization pem files to this folder
  6. Now create "~/.chef/knife.rb" with following content:
    current_dir = File.dirname(__FILE__)
    log_level :info
    log_location STDOUT
    node_name "test"
    client_key "#{current_dir}/saurabh.pem"
    validation_client_name "saurabh-rekall"
    validation_key "#{current_dir}/rekall.pem"
    chef_server_url "https://chefserver/organizations/rekall"
    cache_type 'BasicFile'
    cache_options( :path => "#{ENV['HOME']}/.chef/checksums" )
    cookbook_path ["#{current_dir}/../cookbooks"]
  7. Run "knife user list" and "knife client list" commands to verify whether knife configuration is working
  8. Create "~/cookbooks" folder for cookbooks as specified in ~/.chef/knife.rb

More info on knife configuration is available at https://docs.chef.io/config_rb_knife.html

Steps learned from http://sachinsharm.wordpress.com/2013/10/11/installsetup-and-configure-chef-serverworkstationnode-on-centosrhel-6-4/


Configure a new node to interact with chef-server

  1. To configure a new node to work with chef server use:
    knife bootstrap {{address}} --ssh-user {{user}} --ssh-password '{{password}}' --node-name node1 --run-list 'recipe[learn_chef_httpd]'
    For example
    knife bootstrap 192.168.122.105 --ssh-user root --ssh-password rekall123 --node-name dns



<yambe:breadcrumb>Chef|Chef</yambe:breadcrumb>