External Script Demo

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *

Already have an account? Sign In »

2 hours 51 minutes
Video Transcription
Hello. My name is Jasmine Jackson In our courses Intro to Vagrant And in this video I will show you a demo on how to create an external script. So let's start
Are learning objectives for this video are how to create an is an external script and vagrant So let's start our demo. So I have created a script I s h foul this scripture look familiar as we used it in less than 44
on http server on our machine using secure shell. So now I have an example of I need to install Apache on multiple vagrant machines. I could use a secure shell Teoh each of machine but
that's not really optimal. So what idea? Waas
I created this script that s stage foul and what I'm going to do is I'm going to use this external script inside my vagrant files so I can use provisioning to install the software as soon as I start my vagrant machine.
So let me show you how that works.
Going back to our vagrant foul. In our last video, I shows you a demo on how to create an in line spirit which is here
so Now what we're going to do is we're going to change this in line script to turn into an external script, and the way we're going to do that is we're going to say path
script, that s H.
And the reason we can do that is because our script file is in the same directory as our vagrant file. So we're using a relative path.
If by chance my script file was in a separate location outside of my vagrant file,
then I will have to do an absolute path to specify where my script is in the operating system. But since my script file is in the same directory as my vagary file, I can just use relative paths
and this will work.
So I saved my vaguer file, and now I'm going to go
to Vagrant and I'm going to save vagrant
And as you can see,
our script worked as Apache as our Apache server is being installed.
So sorry for the output really doesn't look the best. But our Apache software has been installed again. So our external scripts works
so less clear,
and I'm going to say vagrant
at this stage,
I want to create a secure shell and to our vagrant machine,
I'm going to go to our Apache folders. So what I'm going to do is type CD for change directory, and then I'm going to type of directory.
And as you can see, we have an index that HTML file, which is our default file and if you notice it was created on December 28th which is today. So our external script was successful.
So to recap, what idea was I created a script to on America Lee install Apache. Http Server on my vagrant machine. So the example I use was I have multiple vagrant machines that I need to install
patching on. And like I said, I could
use a secure show and manually install Apache on each vagrant machine that way, but that's not optimal. So what idea was I created the scripts that I'm going to use in my vagrant foul as an external script
in the way I did that was, I specified a path
to my script file, and again, I'm using relative paths because my script file is in the same directory as my vagrant file Note. If my script foul was not in the same directory as my vaguer file. I would need to use absolute paths,
but I don't need to do that, because my spirit for I was in the same location as my vagrant file. And I could just use the relative path and the vapor foul is smart to know. Okay, let me look at my current directory. Oh, I see a script that s h file. So I'm going to execute that
next we went to Commander, which again is,
uh, council, where you can answer where you can execute linens, commands and windows. And what we did was we did the vagrant provisioned command. And you saw, even though it really wasn't
pretty. But you saw that the Apache http software was being installed so that let us know that our external script worked because as soon as we executed the provisioned command, our software started to install automatically.
And that's the beauty and power of provisioning.
Is that all I have to do is create the script once and then point the script to my vagrant files. And as soon as I as soon as I type the vagrant provisioned command and press answer the
software that I want to be installed automatically installs.
So that's the beauty. All I need to do is create the script
fire once and then point that filed to multiple vagrant files. And as soon as I execute the provision command, that script is automatically executed in that software is automatically installed.
That is very powerful, and it saves you a lot of time. And as I said in the lecture,
you know, using provisioning is automated and repeatable. So are you have to do is
create the scripts one time and that you could automate that and repeat it as many times as you want to. That's very powerful. That saves you a lot of time. You know, while the software is the stalling you could be doing other things in the background is really great. After our path she software
installed, we did a sanity check
by creating a secure shell into our machine and then
changing directories to our Apache. Http. Directory inside our boots to trustee 64 machine and we noticed that there is an index dot html file, which is the Apache default page that I showed you doing our port fording demo
and that Defar page is automatically created when you install Apache.
Because that page let's you know that your installation was successful when you see that page and we know that our external script was successful because we have a date of December 28th and today is December 28th.
So we know that our external script
executed successfully. So now let's return to our lecture. So in summary and this video, we learned how to create an external script in vagrant.
And in our next lecture, I will show you how to share your vagrant machine. We have learned a lot in this course. We downloaded a pre configured vagrant machine. We then you secure shell and installed software. We
created networks
public network, private networks using port fording.
Now we have created in line and external scripts. So now it's like, Hey, I have this great vagrant machine and now I need to share with someone. So in our next lecture, I will show you how to share your vagrant machine with
anyone. So we will create
uh, link for you to share your vagrant machine. And you know you can ship your vagrant machine to anyone that you want to. So I hope you are excited about our next lecture. And also, our next lecture will be our final lecture for this course.
Up Next