Tuesday, August 8, 2017

Applying chef resources


To know,which user we are dealing.

[local@workstation:~]#   whoami
root
[local@workstation:~]# 

now,we are dealing with the root user.

We have a central server,that is the enterprise server.

We have to be familiar with the linux configurations:

We are going to create a basic ruby file:

We are going to create a basic recipe:

The first resource type:package resource type.

The resource name will also act as a package name.

The package for the apache should be the httpd.

Since we are not going to define the package name.it can not only assume the resource name apache,

package 'apache' do
end
~

ruby  -c learn.rb  this will test the ruby syntax

[local@workstation:~]#  ruby -c learn.rb

this does not test,whether the chef syntax is correct.

For example:whether the package is the really resource type.

We can test the chef syntax,using the foodcritic

[local@workstation~]# foodcritic learn.rb
FC011: Missing README in markdown  format:  ../README.md:1
FC031: Cookbook with out metadata file:  ../metdata.rb:1
FC045:  Metadata does not contain cookbook name: ../metadata.rb:1
[local@workstation~]#


we don’t have the readme and metadata with the cookbook information.

Chef-client is a tool that runs the convergence,remember all of the work is done on the machine.

Convergence is going to test the package apache is installed and kept installed if not.

Apache is not the real package name,we will get the error,when we run.

[local@workstation~] # chef-client --local-mode learn.rb
WARN: No config  file found or specified  on command-line, using command line options
WARN: No cookbook directory found at or above current directory 
Starting chef client
resolving cookbooks.





















No comments:

Post a Comment