Recipe : Recipes are nothing but the simple ruby code to manage the system (Nodes). Each recipe is mapped to a provider and Provider completes the action with required steps. And then resources get processed. This phase is called execution phase.
Resources: Each system has multiple components and each component is handle by resource, so resource is component configuration policy
It could be a file, cronjob, service, package
A resource comes with four component : A type, A name, Attributes, Actions
So structure would be :
type "name" do
attribute "value"
action :action_type
end
Note: Every action has its default value, example: package resource default action is :install
package "httpd" equivalent to => package "httpd" do
action :install
end
Here, package is a type and httpd is a name.
Lets look at some actions
Action
:install Does the installation of the resource
:nothing It defines a resource that does nothing.
Resource example with attribute:
service "httpd" do
action :start
retries 3
ignore_failure true
end
Resource of type service and name is httpd will get started as per the defined action. If service is not getting started then still your chef run will not fail as per the defined attribute ignore_failure.
Cookbook: bundle all the recipes and store on chef server
Provider: To make sure that resources are handled in right manner, so there are different providers for different resources
When we right a code to install a package then provider is chosen according to the target platform. And platform is chosen by Ohai. Ohai is a ruby gem installed with chef itself.
Running the Ohai command on my machine for reference:
chef-client: it handled the process of recipes (cookbbok) in two phases.
First Phase: All the recipes are added in run_list would be added in container
Second Phase: All the libraries are loaded with all dependencies. this is called
compilation phase
Guard Attributes: Guard attributes are basically defined to check weather the desired state is present or not for the Chef resource. If the desire state is already presents then chef resource does nothing for the same resource.
it would be a string or a block of ruby code as a value
Block of ruby code may return true or false
String as a value may return 0 (means exit status)
Attribute
not_if if true, dont execute the resource
only_if if true, then execute the resource
And we can use the argument with these attributes as below:
_____________________________________________________________________
Next part is coming soon .....
AWS cloud : Chef
Resources: Each system has multiple components and each component is handle by resource, so resource is component configuration policy
It could be a file, cronjob, service, package
A resource comes with four component : A type, A name, Attributes, Actions
So structure would be :
type "name" do
attribute "value"
action :action_type
end
Note: Every action has its default value, example: package resource default action is :install
package "httpd" equivalent to => package "httpd" do
action :install
end
Here, package is a type and httpd is a name.
Lets look at some actions
Action
:install Does the installation of the resource
:nothing It defines a resource that does nothing.
Resource example with attribute:
service "httpd" do
action :start
retries 3
ignore_failure true
end
Resource of type service and name is httpd will get started as per the defined action. If service is not getting started then still your chef run will not fail as per the defined attribute ignore_failure.
Cookbook: bundle all the recipes and store on chef server
Provider: To make sure that resources are handled in right manner, so there are different providers for different resources
When we right a code to install a package then provider is chosen according to the target platform. And platform is chosen by Ohai. Ohai is a ruby gem installed with chef itself.
Running the Ohai command on my machine for reference:
$ ohai
"filesystem": {
"/dev/disk1": {
"block_size": 512,
"kb_size": 487194624,
"kb_used": 402938164,
"kb_available": 84000460,
"percent_used": "83%",
"inodes_used": "100798539",
"inodes_available": "21000115",
"total_inodes": "121798654",
"mount": "/",
"fs_type": "hfs",
"mount_options": [
"local",
"journaled"
]
},
now lets get back to provider with example:
package "httpd" do
provider Chef::Provider::package::httpd
end
chef-client: it handled the process of recipes (cookbbok) in two phases.
First Phase: All the recipes are added in run_list would be added in container
Second Phase: All the libraries are loaded with all dependencies. this is called
compilation phase
Guard Attributes: Guard attributes are basically defined to check weather the desired state is present or not for the Chef resource. If the desire state is already presents then chef resource does nothing for the same resource.
it would be a string or a block of ruby code as a value
Block of ruby code may return true or false
String as a value may return 0 (means exit status)
Attribute
not_if if true, dont execute the resource
only_if if true, then execute the resource
And we can use the argument with these attributes as below:
package "httpd" do
action :install
not_if{plateform_family?('rhel') && node['plateform_version'].to_f < 6.0 }
end
_____________________________________________________________________
Next part is coming soon .....
0 comments:
Post a Comment