Tuesday, July 18, 2017

Cookbook name apache

#   cookbook name:: apache
#    Recipe::  default
#    Install   apache  package

if node[‘platform_family’]   ==  “rhel”
    package   =  “httpd”
elsif  node[‘platform_family’]   ==  “debian”
     package   =  “apache2”
end

package  ‘apache2’  do 
               package_name package
                action   :  install

end 


service  ‘apache2’  do
               service_name   ‘httpd’
                action   [:start,   :enable]


end
           

we have to validate our code:
  ruby  -c default.rb



we have to validate our code:

 ruby  -c default.rb

similarly with the foodcritic,inorder to make sure it is correct.

    Foodcritic   default.rb


We can write a now recipe called the motd.rb

We are going simply doing the file resource type.


   Resourcename   path
  File   ‘/etc/motd’  do         (the file that we are going to manage).
      Content   ‘Hostname  is  this:  
       (then we are putting node attribute information here).
       (what we are doing here is the combining text with the variable,(node attribute is a variable).
   Inorder to do this,we have to do the variable interpolation.
If we are planning to use the variable interpolation,we cannot use the  ‘ (single quote).

(hostname = node[‘hostname’]
hostname = node attribute of the hostname).


File   ‘/etc/motd’  do         (the file that we are going to manage).
      Content   ‘Hostname  is  this:   hostname (if you put lets this,it will interpret with the line,inorder to the variable hostname

Inorder to do that, we have to change from  single quote to the double quote.

hostname =  node[‘hostname’]
File   ‘/etc/motd’  do         (the file that we are going to manage).
      Content   “Hostname  is  this:   #{hostname}”
       end
This will allow us for the evaluation of the hostname.

As the content in the motd file.
----------------------------------------------------------------------------
version change:

there is a minor change or the major change.

Version     ‘0.1.1’
                   ‘1.    ---à  this is the major change.
                   ‘1.0.0   --à that is the minor change.

The . Is the minor change,
And the third one is considered the patch.

0.1.1     -à   the major change is the first item here.
The second after the .  is the  minor change.(would increment it).
 And the third one is the,be considered the patch.

If it is so major,that is the incompatable,with our node code.we perhaps incompatable with the api change.

We may to consider to change from the one to two.
2.0.0

but if it is a minor change:

we are going to the  0.2.1 

it’s for the patch,we are not fixing the bug,it will actually improve our cookbook.

In this way,it can be stored under version under the chef-server and ofcourse our runlist can define which version.

We can also revert back,if you don’t need to.
  





No comments:

Post a Comment