So let's walk through the validation solution.
So the very first thing that we're going to have to do is to take a copy of the
play to dot yml file.
If I do an ls, here is the file right here.
If I just create a copy of it and I need to create a file called validation dot
yml.
Now I'm going to modify the contents of this playbook so that it uses the
assert module instead of the debug module.
So let's go into the validation dot yml.
As we can see here, we're using the debug module.
So right now I will just go down here, I'll create a new task and I'll just say WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So right now I will just go down here, I'll create a new task and I'll just say
this task will be called assert the value of free memory is above 100.
So in this case here, I will use the Ansible built in assert module.
The require parameter is the that keyword.
And now what I want to do is basically take this test here that we were using
in the when statement.
Okay, so let's copy this and paste it in and what I now want to do to specify
what my success message is going to be.
So right now I will say the free memory is above 100 make and then I'll add in
the value as well. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
the value as well.
So I'll have my double color braces and the value is going to be the free
memory variable.
So I'll say free underscore memory and to get the actual output, I will say dot
STD out.
Now very similar, I also want to have a fail message or say fail underscore MSG
.
In fact, it's not a typo there.
Let me just fix that.
Okay.
And this time I'll say the free memory is below 100 M.
And then once again, I will specify the value and just for posterity, all I
will do is I'll go up and change the name of the playbook.
So it says validation. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So it says validation.
And then the last thing I will do is just get read of this debug module
information.
And in fact, before I run this, because I'm accepting that the value is above
100,
what I'm going to have to do is just make sure that this value here is not less
than 100, but rather greater than 100.
So if it is greater and it is deemed successful, we'll print out this
particular message that it is greater than 100.
And if we are failing this particular test, we can adjust that the memory is
below 100.
So let's actually save this right here. WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So let's actually save this right here.
And let's just try to run the playbook.
We'll say answer my playbook validation that YML answer.
And as we can see here, now we're actually using the asset module to run this
particular test.
Both tests have passed because both tests are over 100.
Now, if I just go to my blue box once again, and if I just run the same test as
I ran before my stress and G dash dash VM two dash dash VM bytes one G and I
answer,
I'm now beginning to stress the memory on the system.
So that if I happen to go back to my playbook and I clear the screen and rerun WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So that if I happen to go back to my playbook and I clear the screen and rerun
the test,
we should have a different output with respect to our blue box.
So let's hit enter now as we can see here now when it comes to the assertion of
the blue box,
we actually get a failure in the case here in our custom message.
We see that we only have 29 meg, whereas our yellow box still has plenty memory
over the 100 meg specification.
And very crucially, like I say in the play recap, we actually see a failure
update.
So that is us for our validation challenge on testing and monitoring using Ans WEBVTT X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000
So that is us for our validation challenge on testing and monitoring using Ans
ible.
I hope it's been informative for you and I'd like to thank you for viewing.