hey guys welcome to the session by Intellipaat in this session we'll be learning
how to set a puppet master slave on top of AWS architecture and before moving
on with the session please subscribe to our channel so that you don't miss our
upcoming videos now let us begin with this session so guys here is my AWS
management console the first thing that I'll do is I'll have to launch an
instance right so I'll select the Ubuntu ami 1 ubantu 18 point o four i'll select this
I select the T 2 dot micro which falls under the free tier I click on next and
select the number of instances as 2 because I want to create one node puppet
master server setup so I'll do I mention the number of instances as 2 I click on
next add storage and then I'll come to security group right so in the security
group what you have to do is you will have to have a security group which
basically will allow TCP connection all TCP connections from the IP address of
your slave right either you can do this or what you can do is you can allow a
TCP connection on the port 8 1 4 0 prom your this particular IP address which is
of the slave if you want to be more specific right but for now what I'm
going to do is I'm gonna open all TCP ports and I'll say it can come from
anywhere and I'll click on review and launch the moment you click on launch
you will be asked to specify the private key that you want to use so I have one
private key already there on my system so I specified that now basically your
instances are getting launched so let's label these instances as master and the
next one would become slave okay so we've specified this and now
while they are launching let's have a look at all the commands that we're
gonna use to basically install my puppet master and slave so guys these are all
the commands so this these commands will basically run on my master and then
these commands will run on my puppet agent right and in the end we are also
going to verify if our master and agent connection is successful by basically
creating a file from the master on the agent with this particular content so
don't worry about it we'll come to this part and I'll explain you what this file
basically means when we get to this part of having the file ready on our system
okay so for now let's start with the master let's start installing master so
let's see if our instances are ready say yes they are in the running State so
let's connect to our master first so this is the master IP address I will
connect through put T specify the private key either now this will
basically let me enter my master server so let me just change the font settings
so it becomes more clear for you and let me choose a color for the master as well
so that we don't get confused between the master and the slave so this is my
master so alright so while I connect to my slave let me just update this machine
so why this machine is getting updated what I can do is I could connect to my
slave so this is my slave guys let's connect to it using putty so this is my
IP address let's specify the private key as well
and now we are connected to our slave as well awesome
let's change the font setting for this let's make it a little bigger so that
you guys can also see this alright so now we are honestly machine let's update
this machine as well alright so meanwhile our master is now updated now
let's go back to our notepad so to see what we have to do next so we have to
install w get first so W get is pre-installed on AWS we
don't have to do this next step is basically to download this particular
file let's do that using W get on the master the file is downloaded and now
let's unzip the file using this command so the file is unzip now let's install
puppet master here so we are installing puppet master puppet master is now being
installed once it's successfully installed we can check the installation
status by going to the policy so obut master is nearly install now and now
let's check the content of the policy so yes puppet master has been successfully
installed and now what I can do is I can check the status of the puppet master
service so this is the service status so it is active and running so that's
awesome so that's what we wanted so our puppet master is now installed on
our system next thing is to basically fine tune some settings so let's do that
so we'll edit this file which basically are the defaults for our puppet master
part for running right here we are so basically your
puppet master by default would use 1 GB of memory but since our system is also 1
GB what we are going to do we have got to mention that the puppet master can
only use 512 MB of the memory so puppet master can work you know 512 MB memory
as well if you are dealing with less number of nodes so since this particular
setup is for our demo purpose so we can mention 512 MB for our puppet master
which should be enough so we'll save the file and now the defaults are ready and
now for applying the defaults we will just restart the puppet master over here
so puppet master is now restarted and now we'll open port 8 1 4 0 through
which basically puppet communicates with the slave through the firewall of the
os as well so that's done and we said so puppet master is successfully set now
let's go to our slave and start setting up our slave as well so on the slave we'll
have a blade of the Machine Wgett is pre-installed we'll first download this
particular file so the file is downloaded let's unzip the file the file
has been and zipped now let's install puppet so earlier we installed puppet
master over here when installing puppet which is nothing but puppet agent right
so what once puppet agent is installed I have to
manually start it and we can do that using this command but before writing
this command what we have to do is we have to go to each machine and change
the host file right so in the host file I have to mention the IP address of
master so we'll have to do this for both the machines
so let's specify the IP address like this and let's specify the masters IP
address in the master as well and in the slave as well too
so we'll do a sudo nano slash g TC slash host specify the IP address right puppet
in front of a and save the file alright so now we are
ready to start the puppet agent so let's do that the puppet agent that has now
been started let's enable puppet as well which basically means on restart also
puppet will be started automatically so this is done as well all right so now as
some steps happen in the background which we were not able to see what were
those steps so that was basically what we discussed in yesterday's class so the
moment puppet slave starts it basically sends a request for the master
certificate how does the puppet slave know where the master is we just specify
the IP address in the host file right so it knows where the puppet master is so
it sends the request the master the master in turn sends the master
certificate and at the same time it also requests for the slave certificate so
this when when the master request for the slave certificate the puppet slave
basically sends the slave certificate and now we have to go to puppet master
basically so we are here we say pseudo puppet sword list right so this should
basically list any certificates which have been sent to the master so let's
check if we have any so as you can see we have a request fall from the puppet
slave on the master so how do we know it's the puppet slave you see this IP
address 172 3144 167 and if we compare it with our slave it's 172 3144 167
right so that's the slaves certificate which has been sent to the master so we
will have to sign it now so for that the command is signed and if there are more
than one certificates or more than two or three certificates and you want to
sign them all all you have to do is pseudo puppet sign and then - - all
specify this and your certificate is now signed right so my puppet master and
puppet slave can now interact with each other so a next step is to verify this
so what we are going to do is we're gonna come
back over here and now basically we are going to create a manifest now what is
the manifest a manifest basically specifies what all changes have to be
made on the agent or on the slave and these are the changes that we are going
to do so basically we are creating a file which exists in this particular
directory right so the puppet master has to ensure that this file is present on
this directory and the permissions the read/write permissions of this file is
this which is the user should be able to read write and the other users of the OS
should be able to read this particular file
ok and what should be the content of this file the content should basically
be it works on and then the IP address of the slave right so this IP address is
gonna change with every machine on which this file is going to exist so this is
going to be the content so let's create this particular file so for that first I
will have to create a path on the master so this is my master let's create a path
path is created now let's edit the manifest file on the master so this is
the manifest file and the content of the file should be this let's copy it paste
it over here save the file and once the file has been saved all you have to do
is restart puppet master so I will restart puppet master like this so my
puppet master has now been restarted and all I have to do is go to the puppet and
since puppet is a full configuration tool the slave has to request for the
changes so I'll say puppet sudo puppet agent - - test right so before I
run this command I want to show you guys there is no file inside temp which
starts with I go inside temp and if I do an LS over here you can see there is no
file called it works so now what we are going to do I'm going to say a pseudo
puppet agent - - test so this command will basically see ask the master for
the is there any changes required for this particular
so the master will send the changes to the agent the agent will make those
changes and send the report back to the master so I'll hit enter now and now you
can see that there has been some things which have been done and you can see a
file has been created in slash templates verify this so let's do an LS now so I
can see a file has been created it works and if I do a cat on this file I can see
the contents of this file is it works on and then the IP address of the slave
which is this right so congratulation guys your puppet master slave setup is
now complete right so now you can use the puppet master slave to basically do
configuration management so you just have to specify the configuration on the
master and then it will be applied on the slave okay guys we've come to the
end of this session I hope this session was informative and
helpful if you have any queries regarding this session please feel free
to come in to it below and we love to help you out thank you