So yes,
welcome to our first demonstration. We're going to be working on our Ubuntu
20.04 system, and we're going to be adding the repositories to allow us to
install Terraform. Once we've got that HashiCorp repositories on, we're able
then to go ahead and install Terraform, and, of course, we're going to be able
to then go through and add in our auto completion and check the versioning,
those sorts of things.
So as we dive out to our glorious command line, we can see it's the
Ubuntu 20.04 system, and we're just about ready to go.
I'm going to make sure that we have got the GIT
repository from the course available to us.
Remember, we've got our sample files that are available
for you to peruse. Now in general,
I don't think it's a particularly good idea if you just copy those files across.
If you get your fingers just a little bit grubby doing some typing,
your learning is probably going to be much more effective
rather than just copying files across.
However, in some cases, it may be worthwhile,
especially where the commands are not necessarily that interesting and
are a little bit verbose. Let me show you what I mean.
If we begin by just taking a look at setting up our repository information,
we see from our slides that it was relatively long‑winded, but if I go
through and cat out from comptia‑automation/terraform and the
terraform_repo.sh, those three lines that we had in the slides are here
set comfortably and tempting to run. Well, the first line, we're doing
the apt update and the apt install just to make sure then that we've got
the software that we need.
We can use curl to download our key, and we can then go ahead and
ensure that we've got the new repository created. Now we've seen
those lines in detail in the slides, so we might as well just go
ahead and execute them.
So bash and Esc and dot will bring up then our script, and we
can see then that we're updating our metadata,
our apt cache.
We can go through then and check that we have already got the software
we needed installed, and then we can go through and add in the
information that we need for our new repository.
Now adding in the new repository, we're also then going to make sure that we
update the cache again to ensure that we've got the latest details for
what's available within our HashiCorp repository.
So whilst it's just thinking about it, it's chugging away, we can see now
that we are reading from the hashicorp.com repositories. And we should be
up and running now being able to install our package for Terraform. So if I
clear out the screen and we can go through elevating our privileges with
our apt install and then ‑y, so we don't get those pesky little prompts and
then our product we want to put on, terraform. Relatively quick that it
should come down so we can allow it to come down, and we should be good to
go. And you know, we can hardly resist it can we, we have to go through and
check out our version, so this is proving then the command is working for
us. So terraform and version, and we can see that we are good to go as far
as that is concerned. However,
we don't get tab completion on our subcommands. So what we can do is to
install the autocomplete scripts, so ‑install‑autocomplete. If we take a
look at that, that will have modified so tail ‑n1 show me the last line of
the .bashrc file, and we can see then that is added in the terraform
program and the terraform subcommand. Rather than log out and log in
again, we can just source our .bashrc file. And now when I go through and
look at terraform and then if I type ver and tab, we get our version
printing out without us having to go through and do all of the typing.
So this is going to save you a lot of time at the command line, and it's definitely something we're going to want.