Code Monkey home page Code Monkey logo

learn-chef's Introduction

How-To setup Chef to manage your servers.

This tutorial will assist you in setting up a Chef Server - hosted at Chef.io , Chef Workstation & Chef Nodes running on AWS as EC2 Instances.

Hosted Chef Server Preparation

  • Create account in chef from manage.chef.io website.
  • Create a organization

Create EC2 Instances to act as nodes

  • Create two instances,
  • One for workstation and
  • Another one to act as the remote node on AWS account
  • The security groups should have the following ports open, 22, 80, 443

Configure Chef Workstation

  • Download Chef starter kit from hosted Chef Server

  • SCP the starter kit into your workstation and unzip in /root directory. It generates /chef-repo.

    yum install unzip -y
    cd /
    unzip chef-starter.zip
    cd /chef-repo
    curl -L https://www.opscode.com/chef/install.sh | bash
  • Validate the SSL certificate & authenticate calls to Chef Server knife ssl check

  • Validate your connection to the Chef server, One way to do that is to run the knife client list command.

  • We have configured our Chef Server(hosted in chef site) and Chef workstation, Authentication is established by the Starter-Kit.

Chef Node[s] bootstrapping

We call the process that installs chef-client on a node and the initial checkin to the Chef server bootstrapping the node.

Bootstrap using key-based authentication

  • Lets tag our node as chef-node01. I used the same tag in EC2 as well to remember it easily.
  • Copy the EC2 key to your workstation to ./chef/chef-node-key.pem
knife bootstrap <EC2_IP_Addr> \
                --ssh-user ec2-user --sudo \
		--identity-file /chef-repo/.chef/<AWS_SSH_Key> \
		--node-name chef-node01
  • To confirm the list of nodes registered to the Chef-Server
knife node list
or
knife node show chef-node01
  • Login to chef node and edit /etc/chef/client.rb file add below line log_level :info

Create cookbook learn-httpd

knife cookbook create learn-httpd
  • Go inside directory cookbooks/learn-httpd/recipes
- cd cookbooks/learn-httpd/recipes
  • Edit default.rb file add below code to install httpd package.
package "httpd"

service "httpd" do
 action [:enable, :start]
end

file '/var/www/html/index.html' do
 content '<h1> I am on top of the world</h1>'
end
  • Upload this new code to your chef server by using below command
knife cookbook upload learn-httpd
  • If you want to double-check your cook books knife cookbook list

  • Now go to your chef node and run chef-client to get latest cookbooks from servers.

chef-client
  • Note: even though our code is currect. It cant install apache. Because we haven’t set this node to run recipes. To do that we should run below command.
knife node run_list add chef-node01 "recipe[learn-httpd]"
  • Run chef-client from your node to run the recipe.

  • Load the webserver page

curl localhost
or
curl <your_public_ip>

Clean up your environment

Delete the node from the Chef server

knife node delete chef-node01 --yes

learn-chef's People

Contributors

miztiik avatar

Watchers

James Cloos avatar

Forkers

vbvbvb696

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.