Chef: installation and few basics

Chef is a configuration management tool written in Ruby and Erlang. It uses a pure-Ruby, domain-specific language (DSL) for writing system configuration “recipes”. Chef is used to streamline the task of configuring and maintaining a company’s servers, and can integrate with cloud-based platforms such as Internap, Amazon EC2, Google Cloud Platform, Oracle Cloud, OpenStack, SoftLayer, Microsoft Azure, and Rackspace to automatically provision and configure new machines. Chef contains solutions for both small and large scale systems. Chef is supported on multiple platforms according to a supported platforms matrix for client and server products.[12] Major platform support for clients includes AIX, RHEL/CentOS, FreeBSD, OS X, Solaris, Microsoft Windows and Ubuntu. Additional client platforms include Arch Linux, Debian and Fedora. Chef Server is supported on RHEL/CentOS, Oracle Linux, Oracle Cloud and Ubuntu.

Before start the Chef tutorial I going to let you know about some Chef specific terminologies :-

  • ChefDK: Chefhttps://www.linuxmint.com/start/tara/ Development Kits
  • Recipe : Files where Chef stores instructions, configuration, commands and so on.
  • CookBook : combination of multiple Recipes called CookBook.
  • Node: In Chef Node refers to target machine that going to be configured.
  • Work Station: refers to the machine from which you are going to instruct Chef to do its works.
  • Chef has Two modes of installation:-
    • Chef-solo: for configuration of single machine
    • Chef-server :for configuration of several machine ( it could be thousand machines

Prerequisites

    • Familiar with Unix/Linux CLI.

Make a file name node.json in root directory:-

{
   "run_list":[
       "recipe[webserver::install_apache]"
   ]
}
  • Familiar with Vagrant and it’s basic command.
  • Familiar with
    Chef Workstation: 0.2.53
      chef-run: .chef-workstation/config.toml.
      chef-client: 14.10.9
      delivery-cli: 0.0.52 (9d07501a3b347cc687c902319d23dc32dd5fa621)
      berks: 7.0.7
      test-kitchen: 1.24.0
    Chef Workstation: 0.2.53
      chef-run: .chef-workstation/config.toml.
      chef-client: 14.10.9
      delivery-cli: 0.0.52 (9d07501a3b347cc687c902319d23dc32dd5fa621)
      berks: 7.0.7
      test-kitchen: 1.24.0
      inspec: 3.6.6
    

    Chef workstation has installed. Next, would like to show you few basic configuration by install apache2 server in a node using recipe, cookbook and so on. In this article I configure everything in chef-solo mode, That mean apache2 will configure and install in a single and same workstation.</https://99coding.club/wp-admin/post.phpspan>

    At first make a new directory in /vagrant directory
    inspec: 3.6.6

    Chef workstation has installed. Next, would like to show you few basic configuration by install apache2 server in a node using recipe, cookbook and so on. In this article I configure everything in chef-solo mode, That mean apache2 will configure and install in a single and same workstation.</https://99coding.club/wp-admin/post.phpspan>

    At first make a new directory in /vagrant directoryuntu.com/”>CentOS

    and Ubuntu.

  • Familiar with SSH.
  • Basic Networking and Client-Server communicat
    cd /vagrant
    sudo mkdir -p cookbooks1/webserver/recipes
    cd cookbooks1/webserver/recipes/
    

    ion Knowledge.

Chef Installation

I am going to install Chef workstation in a Ubuntu vagrant machine. So, I assume that vagrant is already installed in your machine. Firstly, make a directory named chef_tut enter into it and execute vagrant init command in it. Edit the vagrantfile as following:-

comment out line 15:-

# config.vm.box = "base"

add following code between line 69 and line 70

config.vm.define "chef" do |chef|
   chef.vm.hostname = "chef"
   chef.vm.box = "bento/ubuntu-16.04"
   chef.vm.network "private_network", ip: "192.168.33.100"
 end

Save the vagrantfile and start the vagrant host named chef vagrant up chef . Now enter the chef host and start installation of Chef Workstation into it. vagrant ssh chef

Visit this

Chef Workstation: 0.2.53
  chef-run: .chef-workstation/config.toml.
  chef-client: 14.10.9
  delivery-cli: 0.0.52 (9d07501a3b347cc687c902319d23dc32dd5fa621)
  berks: 7.0.7
  test-kitchen: 1.24.0
  inspec: 3.6.6

Chef workstation has installed. Next, would like to show you few basic configuration by install apache2 server in a node using recipe, cookbook and so on. In this article I configure everything in chef-solo mode, That mean apache2 will configure and install in a single and same workstation.</https://99coding.club/wp-admin/post.phpspan>

At first make a new directory in /vagrant directoryworkstation/0.2.53″>url

to download chef workstation. You could find here Chef workstation for almost every platform. Our OS is Ubuntu-16.04; So scroll down and find the download link for Ubuntu-16.04. We will use wget to download. So, copy the download link and use with wget:-
==============================================================================================================

============================================================================================================

After successful downloaded , now install the chef package using Ubuntu Default Package Manager or dpkg;-

sudo dpkg -i chef-workstation_0.2.53-1_amd64.deb

Make a file name node.json in root directory:-

/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
    - install version 2.4.18-2ubunt
/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
    - install version 2.4.18-2ubuntu3.10 of package apache2
  * service[apache2] action start (u
/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
    - install version 2.4.18-2ubuntu3.10 of package apache2
  * service[apache2] action start (up to date)
  * service[apache2] action enable (up to date)

ed correctly or not by using curl:-p to date)
  * service[apache2] action enable (up to date)

ed correctly or not by using curl:-u3.10 of package apache2
  * service[apache2] action start (up to date)
  * service[apache2] action enable (up to date)
/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
    - install version 2.4.18-2ubuntu
/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
    - install version 2.4.18-2ubuntu3.10 of package apache2
  * service[apache2] action start (u
/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
    - install version 2.4.18-2ubuntu3.10 of package apache2
  * service[apache2] action start (u
/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
    - install version 2.4.18-2ubuntu3.10 of package apache2
  * service[apache2] action start (up to date)
  * service[apache2] action enable (up to date)

ed correctly or not by using curl:-p to date)
  * service[apache2] action enable (up to date)

ed correctly or not by using curl:-p to date)
  * service[apache2] action enable (up to date)

ed correctly or not by using curl:-3.10 of package apache2
  * service[apache2] action start (up to date)
  * service[apache2] action enable (up to date)

ed correctly or not by using curl:-
ed correctly or not by using curl:-l
/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
    - install version 2.4.18-2ubuntu3.10 of package apache2
  * service[apache2] action start (up to date)
  * service[apache2] action enable (up to date)

ed correctly or not by using curl:-ighter-language="json">{
   "run_list":[
       "recipe[webserver::install_apache]"
   ]
}

Create a configuration file solo.rb in same level of node.json:-
now test the installation executing chef --version command. If everything installed correctly then you will see the output like this:-

/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
    - install version 2.4.18-2ubuntu3.10 of package apache2
  * service[apache2] action start (up to date)
  * service[apache2] action enable (up to date)

ed correctly or not by using curl:-ighter-linenumbers="false">Chef Workstation: 0.2.53
  chef-run: .chef-workstation/config.toml.
  chef-client: 14.10.9
  delivery-cli: 0.0.52 (9d07501a3b347cc687c902319d23dc32dd5fa621)
  berks: 7.0.7
  test-kitchen: 1.24.0
  inspec: 3.6.6

Chef workstation has installed. Next, would like to show you few basic configuration by install apache2 server in a node using recipe, cookbook and so on. In this article I configure everything in chef-solo mode, That mean apache2 will configure and install in a single and same workstation.</https://99coding.club/wp-admin/post.phpspan>

/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
    - install version 2.4.18-2ubuntu3.10 of package apache2
  * service[apache2] action start (up to date)
  * service[apache2] action enable (up to date)

ed correctly or not by using curl:-
At first make a new directory in /vagrant directory
cd /vagrant
sudo mkdir -p cookbooks1/webserver/recipes
cd cookbooks1/webserver/recipes/

Make a recipe file name install_apache.rb and add fololwing Ruby codes:-

package "apache2" do
   action :install
end
# A resource
service "apache2" do
   action [:start,:enable]
end
Chef Workstation: 0.2.53
  chef-run: .chef-workstation/config.toml.
  chef-client: 14.10.9
  delivery-cli: 0.0.52 (9d07501a3b347cc687c902319d23dc3
{
   "run_list":[
       "recipe[webserver::install_apache]"
   ]
}

2dd5fa621)
berks: 7.0.7
test-kitchen: 1.24.0
inspec: 3.6.6

Chef workstation has installed. Next, would like to show you few basic configuration by install apache2 server in a node using recipe, cookbook and so on. In this article I configure everything in chef-solo mode, That mean apache2 will configure and install in a single and same workstation.</https://99coding.club/wp-admin/post.phpspan>

At first make a new directory in /vagrant directory

Make a file name node.json in root directory:-

{
   "run_list":[
       "recipe[webserver::install_apache]"
   ]
}

Create a configuration file solo.rb in same level of node.json:-

CHEF_ROOT="/vagrant"
cookbook_path "#{CHEF_ROOT}/cookbooks"
json_attribs "#{CHEF_ROOT}/node.json"

Now we have enough configuration and recipe to cook in kitchen. Execute chef-solo command as below:-

sudo chef-solo -c solo.rb

https://99coding.club/wp-admin/post.php
After successful execution of chef-solo command, we can seen output like this:-

{
   "run_list":[
       "recipe[webserver::install_apache]"
   ]
}

“false”>/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: [“webserver::install_apache”]
Synchronizing Cookbooks:
– webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks…
Converging 2 resources
Recipe: webserver::install_apache
* apt_package[apache2] action install
– install version 2.4.18-2ubuntu3.10 of package apache2
* service[apache2] action start (up to date)
* service[apache2] action enable (up to date)

Running handlers:
Running handlers complete
Chef Client finished, 1/3 resources updated in 34 seconds

We can check whether apache2 install

Prerequisites

    https://99coding.club/wp-admin/post.php

  • Familiar with Unix/Linux CLI.
  • Familiar with Vagrant and it’s basic command.
  • Familiar with CentOS and Ubuntu.
  • Familiar with SSH.
  • Basic Networking and Client-Server communication Knowledge.
/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
    - install version 2.4.18-2ubuntu3.10 of package apache2
  * service[apache2] action start (up
/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action insta
/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
    - install version 2.4.18-2ubuntu3.10 of package apache2
  * service[apache2] action start (up to date)
  * service[apache2] action enable (up to date)

ed correctly or not by using curl:-ll
    - install version 2.4.18-2ubuntu3.10 of package apache2
  * service[apache2] action start (up to date)
  * service[apache2] action enable (up to date)

ed correctly or not by using curl:- to date)
  * service[apache2] action enable (up to date)

ed correctly or not by using curl:-

Chef Installation

I am going to install Chef workstation in a Ubuntu vagrant machine. So, I assume that vagrant is already installed in your machine. Firstly, make a directory named chef_tut enter into it and execute vagrant init command in it. Edit the vagrantfile as following:- comment out line 15:-

# config.vm.box = "base"

add following code between line 69 and line 70

config.vm.define "chef" do |chef|
   chef.vm.hostname = "chef"
   chef.vm.box = "bento/ubuntu-16.04"
   chef.vm.network "private_network", ip: "192.168.33.100"
 end
/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <!--
    Modified from the Debian original for Ubuntu
    Last updated: 2014-03-19
    See: https://launchpad.net/bugs/1288690
  -->
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Apache2 Ubuntu Default Page: It works</title>
    <style type="text/css" media="screen">

– install version 2.4.18-2ubuntu3.10 of package apache2
* service[apache2] action start (up to date)
* service[apache2] action enable (up to date)

ed correctly or not by using curl:-
Save the vagrantfile and start the vagrant host named chef vagrant up chef . Now enter the chef host and start installation of Chef Workstation into it. vagrant ssh chef

Visit this url to download chef workstation. You could find here Chef workstation for almost every platform. Our OS is Ubuntu-16.04; So scroll down and find the download link for Ubuntu-16.04. We will use wget to download. So, copy the download link and use with wget:-
======================================================================================================================================

==================================================================================================================
After successful downloaded , now install the chef package using Ubuntu Default Package Manager or dpkg;-

sudo dpkg -i chef-workstation_0.2.53-1_amd64.deb

now test the installation executing chef --version command. If everything installed correctly then you will see the output like this:-

Chef Workstation: 0.2.53
  chef-run: .chef-workstation/config.toml.
  chef-client: 14.10.9
  delivery-cli: 0.0.52 (9d07501a3b347cc687c902319d23dc32dd5fa621)
  berks: 7.0.7
  test-kitchen: 1.24.0
  inspec: 3.6.6

Chef workstation has installed. Next, would like to show you few basic configuration by install apache2 server in a node using recipe, cookbook and so on. In this article I configure everything in chef-solo mode, That mean apache2 will configure and install in a single and same workstation.</https://99coding.club/wp-admin/post.phpspan>

At first make a new directory in /vagrant directory

cd /vagrant
sudo mkdir -p cookbooks1/webserver/recipes
cd cookbooks1/webserver/recipes/

Make a recipe file name install_apache.rb and add fololwing Ruby codes:-

package "apache2" do
   action :install
/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
    - install version 2.4.18-2ubuntu3.10 of package apache2
  * service[apache2] action start (up to date)
  * service[apache2] action enable (up to date)

ed correctly or not by using curl:-
end
# A resource
service "apache2" do
   action [:start,:enable]
end

Make a file name node.json in root directory:-

{
   "run_list":[
       "recipe[webserver::install_apache]"
   ]
}

Make a file name node.json in root directory:-

{
   "run_list":[
       "recipe[webserver::install_apache]"
   ]
}

Create a configuration file solo.rb in same level of node.json:-

{
   "run_list":[
       "recipe[webserver::install_apache]"
   ]
}

Create a configuration file solo.rb in same level of node.json:-

CHEF_ROOT="/vagrant"
cookbook_path "#{CHEF_ROOT}/cookbooks"
json_attribs "#{CHEF_ROOT}/node.json"

Now we have enough configuration and recipe to cook in kitchen. Execute chef-solo command as below:-

sudo chef-solo -c solo.rb

https://99coding.club/wp-admin/post.php
After successful execution of chef-solo command, we can seen output like this:-

/vagrant/solo.rb:1: warning: already initialized constant Class::CHEF_ROOT
/vagrant/solo.rb:1: warning: previous definition of CHEF_ROOT was here
Starting Chef Client, version 14.10.9
resolving cookbooks for run list: ["webserver::install_apache"]
Synchronizing Cookbooks:
  - webserver (0.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: webserver::install_apache
  * apt_package[apache2] action install
    - install version 2.4.18-2ubuntu3.10 of package apache2
  * service[apache2] action start (up to date)
  * service[apache2] action enable (up to date)

ed correctly or not by using curl:-
==============================================================================================================

=======================================================================================================================

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <!--
    Modified from the Debian original for Ubuntu
    Last updated: 2014-03-19
    See: https://launchpad.net/bugs/1288690
  -->
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Apache2 Ubuntu Default Page: It works</title>
    <style type="text/css" media="screen">

 

Leave a Reply

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