The first command for creating the connection is
bootstrapping.
Downloaded the starter kit from the hosted chef.
If you download the starter kit for the second time (the
.pem in the host will be changed and it will create problems).
note:once you downloaded the starter kit,It may halt your
existing connections.
Steps(This is on
windows machine)
1 Install the Chef DK (Google it).
2 Install visual studio code/Atom/Sublime
(Every dev activity will be on workstation).
1 All the practice is down from the
powershell.
We have to
tune that Editor (Visual studio code).
Boiler
plate means something which editor gives.
We
have to take the path from the local machine.
it
gives the autogenerated script.
(something
like a basic boilerplate).
these are
related to the user resources.
We have to just change the values.
These are all the resources,for
some of the resources we get the help like this.
Note:
These kind of editors
will help us to reduce the Dev time.
We have to break our
file in to multiple recipe files.
we can right click and create a new file,which is called as
test.rb
(text editor,will make your work faster).
We generated the
cookbook now and things are good now,the problem is,you will not be able to do
the work with one recipe file.
How to generate the
recipe?
Chef generate recipe
<COOKBOOK’S PATH> <recipe name>
(if you want to call any recipe,the naming convention is):
cookbookname::recipename
(this is the common convention).
Example:
myfirst::other
By default,we have is:
myfirst::default
These are the
basic/most frequently used:
Installations
Create files or directories
Create users or groups
Manage services
Modify configuration files
Copy/download files
Extract zip/tars
(these are the part
of the most of the installations).
Rare scenarios:
Manage ports/firewalls
(covers 80% of the installation).
Jenkins
(how to get this,up and running).
Google > installing Jenkins on Ubuntu 14.04 (Be
explicit on your version also).
(select digitialocean
articles).
Manual steps for
Jenkins installations:
what is wget command
==è download
wget -q -O
- http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt-key add -
After that,it is
using,echo statement:
echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list
(we don’t have a
equivalent command of echo statement,so
we might,need to use to chef,it may use some linux command).
Apt-get update
Apt-get install jenkins
(In chef,we have to
write package Jenkins).
Chef process for
Jenkins:
I want to create a
recipe here for installations.
Xxxxxxxxxxx\chef-repo\cookbooks\myfirstcookbook> chef
generate recipe .(currentdirectory)
Jenkins_apt
Note:
(when your writing
recipes,your approach is in two ways,that is one is the regular way on Ubuntu
and another recipe is for the tomcat server).
Requirement: I
want to install Jenkins on tomcat server instead of Ubuntu server:
1)Installing tomcat on Ubuntu:
(first I have to install tomcat,then I have to install
Jenkins).
(someone will ask tomcat,not only for Jenkins purpose right)
What is Tomcat?
Tomcat is an application server.
(inorder to that,we have to write two recipes,one is for
tomcat installation and another for the Jenkins).
Xxxxxxxxxxx\chef-repo\cookbooks\myfirstcookbook> chef generate recipe .(currentdirectory) tomcat_install
(to separate two
words they use _ (underscore)) -Ã ruby convention
Xxxxxxxxxxx\chef-repo\cookbooks\myfirstcookbook> chef generate recipe .(currentdirectory) Jenkins_tomcat_install
Whenever you installing Vagrant,make sure that,your Bios -Ã virtualisation is
enabled.
(if virtualization is disabled,we cannot do it).
In the chef-repo path
>
We have to create a directory > local env(d) >
Ubuntu (d)
Xxxxxxxxxxxxx/chef-again/localenv/ubuntu12
$ vagrant init
hashicorp/precise64
if everything is fine,you should see a Vagrantfile here.
if your doing in windows,follow the git bash
$vagrant up
we want to create
another machine -Ã Ubuntu 14.04
Ubuntu14 (directory)
git bash (windows
machine) > $ vagrant init Ubuntu/trusty64 (a Vagrantfile will be created)
$ vagrant up
Note:
We can write multiple
tasks in a recipe,programmatically yes,but design wise its not a good practice.
How to ssh in to the
vagrant machine?
The (username of
vagrant,will always be the vagrant machine).
If your using the git
bash (only for windows machine).
$ vagrant ssh
Steps for installing
the tomcat:
Sudo apt-get update
(to do apt-get
update,what resource we have to use In
chef).
Sudo apt-get install tomcat7
(ubuntu14.04)
(we need to know,what resources we have to use,to achieve
this).
Chef resources (google)
Apt-get update
Use the apt_update resource to manage APT repository
updates on Debian and Ubuntu platforms.
New in Chef Client 12.7.
In tomcat_install.rb
(this is how,we have to write a recipe).
#This automation
is done based on
apt_update ‘update
ubuntu’ do
action :update
(basically apt-update
have three actions
:nothing
:periodic
:update).
End
Note
Apt_package (your
telling that,its only works on Ubuntu)
The difference
between apt_package(only
Ubuntu),package(this works everywhere) and yum_package(only centos) is
Package ‘tomcat’ do
Action :install
End
Note:
Whenever we install
tomcat > we have the webapps folder > in this folder we have to copy the file,which
we downloaded from the Jenkins,which is Jenkins.war
Steps:
Goto : https://jenkins .io/download/
And download the Generic
java package (war)
In Jenkins_tomcat_install.rb
#Jenkins locations to download
#webapps folder location
---Ã /var/lib/tomcat/webapps
Manual process
The link whatever you copied that is the Jenkins.war and
will be downloaded in the webapps directory.
/var/lib/tomcat7/webapps
# wget
http://ftp.yz……………/jenkins/war-stable/2.46.2/jenkins.war
(wget will download the war file from there(downloads
directory,where you rightlink you get the above link address).
Once this is done we will restart the Jenkins and restart
tomcat,this shouldwork.
(you want to execute
a command,that equivalent resource is not found directly,then we have to run
the linux command directly).
$ service tomcat7
restart
(we have to ipaddress to the machine,we have to go inside
the Vagrantfile and uncomment the
ipaddress ).
When that done,we
have to give:
$vagrant load
Verifying:
$sudo service tomcat7
status
After that:
we have to know,what
resource we have to use for download:
command resource
apt-get update apt_update
need to create a
table for command and resources --> *****
(linux (command)
-----------> chef(resource))
Upload this cookbook:
Knife upload cookbook cookbookname
If you want to add directly to the run_list
knife node add nodename run_list recipe(cookbook::recipename)
Hi Very nice blog thank you for sharing this blog.
ReplyDeleteDevOps Training
DevOps Online Training
Great Article, thank you for sharing this useful information!!
ReplyDeleteThank you for sharing valuable information.This article is very useful for me valuable info about cookbooks.
DevOps Training in Chennai
DevOps Online Training in Chennai
DevOps Training in Bangalore
DevOps Training in Hyderabad
DevOps Training in Coimbatore
DevOps Training
DevOps Online Training