Ruby is a simple readable language.
Recipes will be having something called as Resources.
In chef,we called it as a resources
In Ansible,we called It as a module.
(for every tool,the name which you called is different).
My things: (Manual steps).
1) Installing Tomcat
a)
Yum install tomcat
In chef รจ what resource can I use to achieve this ?
(we can use :
package
yum
(A resource
means something which will do action for us).
If you
samething on the Ubuntu server:
b)
Apt-get
install tomcat7
2) Creating a directory /var/log/tomcat
Mkdir
/var/logs/tomcat
3) Starting tomcat services.
Service tomcat
enable
Service tomcat
start
(these are
manually executed)
End
steps ,which I need to do is the deployment on the redhat machine.
Something,we need to make this unit
services,reusable we use the resources:
For example:
Write a file,
a=tomcat b=/var/logs/tomcat
Yum install a
Mkdir b
Service a start
Note:
If you want to change to httpd in place of tomcat we can
change to the a = httpd
For example:
You want to install nginx change a = nginx
Every tool has its own way of defining the variables.
In chef,it is
popularly called it as attributes and databags.
If the resources are
not present,what to do?
Recipes rely primarily on resources, resources described a desired state of an element in the infrastructure.
What is Chef?
"Chef turns infrastructure into code.With Chef,you can automate how you build, deploy and manage your infrastructure.Your infrastructure becomes as versionable,testable and repeatable as application code.
Chef relies on reusable definitions knows as recipes are instructions for configuring web servers, databases and load balancers.Together,recipes describe what your infrastructure consists of and how each part of your infrastructure should be deployed, configured and managed.
- Packages to be installed
- Files to be created
- Directories to be created
- Services to be started
- Config files to be updated
- Commands to be executed
Common Chef Terminology
Recipes:
Fundamental configuration element within an organization.
Cookbooks:
Defines a scenario and is the fundamental unit of configuration and policy distribution.
Convergence:
Occurs when chef-client configures the system/node based off the information collected from chef-server.
Configuration Drift:
Occurs when the node state does not reflect the updated state if polices/configurations on the chef-server.
Resources:
A statement of configuration policy within a recipe
Describes the desired state of an element in the infrastructure and steps needed to configure.
when we install python.
For operating system point of view,we see here:
Apt-get install
python
Apt-get install
python-pip
(that means the provider is apt-get )
when it comes to the awscli language:
pip install awscli
(pip is the provider).
Provider is the
thing,which does the work.
If anyone asks to do the installation on ruby:
There is something called the rubygem
(who does this
work,those are called as a provider).
In the first two statements the provider is apt-get
And the last one the provider is the pip
Chef-repo is the chef repository,what it contains,it
contains:it is the area where it contains chef scripts.
Why it is special:because it contains details about the
chef-server.
When you create an account in hosted chef,you will be creating an
organsation.
(it is an isolation,you create across team).
For every organsation you will have the chef-repo.
Note:for two organsations,you don’t have a same chef-repo.
Learn how to write
chef recipes?
Always dealing with the topmost item:
The topmost item is cookbook
Recipes
Resources
For that,we are using a tool called the knife.
The timer starts the moment
you install chef (because the chef node will
interact with the chef server for every 30 minutes,to apply the new
policies).
Note:
First thing,ensure that,all of the servers are installing chef-client
at sametime.
(so that,for example you install the chef-client at 7.00 am
and the convergence will happen at the 7:30,so ensure that the chef-client
installation on the chef nodes are installed at the same time).
Whenever you execute knife command,you have to be in
chef-repo:
download the starter kit from the chef-server > starter
kit > chef-repo > this is the
directory structure.
Whatever the cookbook that is given to you by default,it is
the starter cookbook.
The problem here
is,you did not install chefdk:
you have to install chefdk in your local workstation,here
localworkstation is the VM.
For example:
Install chefdk on
windows:
this is the thing,how
to install chefdk on the windows machine.
before writing anything inside the recipes,we have to know
about the chef resources
just type chef resources in the google
Note:
What we have to pass -------ร
is the attributes and values.
What has to be done
----ร
is the action.
Example: Install the tree on
my node:
Going to use the resource package (which is in the chef
documentation).
Note:
When you upload to
the chef server,we upload it as a cookbook.
When you add it to
the run_list,we add it as a recipe.
When your adding to
the run_list : your going to tell in this manner:
Recipe[cookbookname::recipename(it
is a filename,with out .rb)]
Recipe[helloworld::default]
(we have to
remember,we have to add the recipes in the run_list).
Now your assigning
recipe,to be a part of convergence:
recipe [cookbookname::recipename]
recipe [helloworld::default1]
knife node run_list add <NODE> "recipe[motd]"
No comments:
Post a Comment