WEBVTT

1
00:00.000 --> 00:02.320
Okay, so let's get started on the solution.

2
00:02.320 --> 00:04.980
So the very first time we're going to have to do it is to create three new

3
00:04.980 --> 00:06.000
groups on both

4
00:06.000 --> 00:09.600
of our managed devices called valid one, valid two and valid three.

5
00:09.600 --> 00:14.160
So let's create our playbook, save them validation dot ymel, going to insert

6
00:14.160 --> 00:14.560
mode,

7
00:14.560 --> 00:16.000
have our three hyphens at the top.

8
00:16.000 --> 00:19.680
Let's just give this a name, just call this validation playbook.

9
00:19.680 --> 00:22.000
Now we're going to do this on all of our devices.

10
00:22.000 --> 00:25.520
So the groups I'm going to target will be the all group and I don't need to

11
00:25.520 --> 00:26.320
gather facts.

12
00:26.320 --> 00:28.000
So I'll just set that to false.

13
00:28.000 --> 00:31.680
And what I'm now going to do is I'm going to create my groups.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

13
00:28.000 --> 00:31.680
And what I'm now going to do is I'm going to create my groups.

14
00:31.680 --> 00:37.130
So to specify my tasks and I'll give this a name or say create first group and

15
00:37.130 --> 00:37.360
I'll use

16
00:37.360 --> 00:39.520
the answerable built in group module.

17
00:39.520 --> 00:43.200
And the name of the group is going to be valid one and the state is going to be

18
00:43.200 --> 00:43.920
present.

19
00:43.920 --> 00:47.440
Now in the interest of time, let me just copy this right here and I'll just

20
00:47.440 --> 00:48.400
paste this in again.

21
00:48.400 --> 00:50.160
All I will do is make some modifications.

22
00:50.160 --> 00:54.530
I'll just say create the second group and I'll change this to valid two for the

23
00:54.530 --> 00:55.200
group name.

24
00:55.200 --> 00:58.480
And again, for the third group, let me just paste this in and I'll change this

25
00:58.480 --> 00:59.120
to create

26
00:59.120 --> 01:02.160
third group and the group will be called valid three.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

26
00:59.120 --> 01:02.160
third group and the group will be called valid three.

27
01:02.160 --> 01:04.560
So that will ensure that we have our three groups created.

28
01:04.560 --> 01:08.080
So now what I want to do is I want to create a user called valid user,

29
01:08.080 --> 01:12.350
give them a Ben Bash shell and grant the account group access to the three

30
01:12.350 --> 01:13.680
groups we just created.

31
01:13.680 --> 01:17.280
So let's give this one a name or say creates user accounts.

32
01:17.280 --> 01:20.720
I'm going to use the answerable built in user module this time.

33
01:20.720 --> 01:23.760
The name is going to be valid underscore user.

34
01:23.760 --> 01:27.440
The shell is going to be forward slash Ben forward slash bash

35
01:27.440 --> 01:30.720
and now specify the groups that that user should be a member of.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

35
01:27.440 --> 01:30.720
and now specify the groups that that user should be a member of.

36
01:30.720 --> 01:33.040
So the first group we're going to join is going to be valid one.

37
01:33.040 --> 01:36.160
Then we'll have a comma to specify the next group, which is valid two,

38
01:36.160 --> 01:38.800
then a comma and add valid three.

39
01:38.800 --> 01:42.720
So the next task is going to be give the account a password.

40
01:42.720 --> 01:46.880
So what I'm going to do here is use the answerable built in shell module

41
01:46.880 --> 01:50.560
and I'll just echo out the password variable, which I haven't created yet.

42
01:50.560 --> 01:54.480
I'll do that in a moment and I'll pipe that in to the past wd command,

43
01:54.480 --> 01:58.640
specify s cd in and then feed in the user variable.

44
01:58.640 --> 02:02.080
So like I say, we actually haven't defined these particular values.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

44
01:58.640 --> 02:02.080
So like I say, we actually haven't defined these particular values.

45
02:02.080 --> 02:05.030
So what I will do is I'll go up to the very top right here and I'll define my

46
02:05.030 --> 02:05.680
verse.

47
02:05.680 --> 02:09.150
So I'll just create a variable called user and the user is going to be valid

48
02:09.150 --> 02:09.760
user

49
02:09.760 --> 02:12.800
and the password will as per the instruction, we're going to have to give a

50
02:12.800 --> 02:14.320
password of nuggets.

51
02:14.320 --> 02:16.560
So what I will do here is say nuggets.

52
02:16.560 --> 02:20.570
And in fact, since we actually have a variable for valid user, let me go down

53
02:20.570 --> 02:20.880
here.

54
02:20.880 --> 02:24.720
And as opposed to hard coding this, I'll just use the variable value.

55
02:24.720 --> 02:28.000
And now with that done, the last thing I'm going to have to do is to give this

56
02:28.000 --> 02:28.400
user

57
02:28.400 --> 02:29.680
support user privileges.

58
02:29.680 --> 02:31.280
So let's give a name for the next task.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

58
02:29.680 --> 02:31.280
So let's give a name for the next task.

59
02:31.280 --> 02:33.680
And we just give the user sudo paths.

60
02:33.680 --> 02:36.960
So I'll use the answerable built in line and file module.

61
02:36.960 --> 02:38.880
What is the path I want to manipulate?

62
02:38.880 --> 02:42.640
You guessed it's going to be forward slash Etsy forward slash sudoers.

63
02:42.640 --> 02:45.280
The line I'm going to add in this case here,

64
02:45.280 --> 02:47.280
I would just say valid user.

65
02:47.280 --> 02:50.640
And then within capital letters, I will say all is equal to and then open my

66
02:50.640 --> 02:51.520
parentheses,

67
02:51.520 --> 02:56.640
all colon all close parentheses and then just say all and capital letters again

68
02:56.640 --> 02:57.760
and close my

69
02:57.760 --> 02:58.560
quotations.

70
02:58.560 --> 03:01.280
And then of course, for good practice, we're going to validate what we've just
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

70
02:58.560 --> 03:01.280
And then of course, for good practice, we're going to validate what we've just

71
03:01.280 --> 03:01.600
done.

72
03:01.600 --> 03:06.560
So we'll use the command vice sudo -cf to check the file and then percentage is

73
03:06.560 --> 03:07.760
to pass in the actual

74
03:07.760 --> 03:08.800
file we're working with.

75
03:08.800 --> 03:10.000
And where do we want to add this?

76
03:10.000 --> 03:13.120
We're going to use the insert after parameter.

77
03:13.120 --> 03:15.280
And they want to insert at the end of the file.

78
03:15.280 --> 03:18.800
So with that now done, everything should be up and running.

79
03:18.800 --> 03:21.920
So let's just press colon wq to write in quotes.

80
03:21.920 --> 03:26.560
And I'll just say answerable -playbook validation.yaml and to answer.

81
03:26.560 --> 03:29.520
Open appears we have a little bit of a syntax error.

82
03:29.520 --> 03:31.840
And appears I have a slight indentation error.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

82
03:29.520 --> 03:31.840
And appears I have a slight indentation error.

83
03:31.840 --> 03:32.640
Notice this?

84
03:32.640 --> 03:33.360
This is the trick.

85
03:33.360 --> 03:35.600
This is the trick of working with yaml.

86
03:35.600 --> 03:37.520
So I'm going to have to knock it in one space.

87
03:37.520 --> 03:39.840
So move that in and again down here.

88
03:39.840 --> 03:41.520
Let's also fix the indentation.

89
03:41.520 --> 03:43.520
Okay, so that should be the indentation fixed.

90
03:43.520 --> 03:44.800
And run the playbook.

91
03:44.800 --> 03:47.040
And appears everything has ran successfully.

92
03:47.040 --> 03:48.400
So let's go to our devices.

93
03:48.400 --> 03:52.400
So if I cat the ec group file right here, we can see we have added these three

94
03:52.400 --> 03:52.720
groups

95
03:52.720 --> 03:56.160
in valid user as a member of the three groups, which is a good sign.

96
03:56.160 --> 03:58.400
Let's try to log in as a valid user.

97
03:58.400 --> 04:03.120
So say su valid user and I'll type in the password nuggets.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

97
03:58.400 --> 04:03.120
So say su valid user and I'll type in the password nuggets.

98
04:03.120 --> 04:05.760
And if I say who am I, we can see we are the valid user.

99
04:05.760 --> 04:11.120
And if I just say sudo cat, ec sudoers, that should open up the sudoers file.

100
04:11.120 --> 04:14.160
And I'll type in my password of nuggets to confirm.

101
04:14.160 --> 04:16.080
Notice we have super user access.

102
04:16.080 --> 04:20.210
And we can see here at the very end of the file we have indeed inserted the

103
04:20.210 --> 04:20.640
information

104
04:20.640 --> 04:22.640
for valid user to be a super user.

105
04:22.640 --> 04:25.120
And again on blue box, let's cat ec group.

106
04:25.120 --> 04:27.760
We can see valid user as a member of the three groups.

107
04:27.760 --> 04:31.120
And again, we could also say id valid user to see that information.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

107
04:27.760 --> 04:31.120
And again, we could also say id valid user to see that information.

108
04:31.120 --> 04:32.800
There are the three groups right there.

109
04:32.800 --> 04:37.120
And let's substitute into the valid user, type in the password of nuggets.

110
04:37.120 --> 04:38.480
We now see who am I.

111
04:38.480 --> 04:43.720
And if I open up the ec sudoers file using the sudo command, we do have super

112
04:43.720 --> 04:44.320
user access.

113
04:44.320 --> 04:47.840
I'll type in the password nuggets and we can see here we can actually read that

114
04:47.840 --> 04:48.480
file

115
04:48.480 --> 04:52.730
using our elevated privileges and at the very bottom, there is the valid user

116
04:52.730 --> 04:53.200
account.

117
04:53.200 --> 04:56.080
And again, just to confirm, I can say sudo dnf updates.

118
04:56.080 --> 05:00.240
And as we can see here, the command is available to us and we can just say why
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

118
04:56.080 --> 05:00.240
And as we can see here, the command is available to us and we can just say why

119
05:00.240 --> 05:01.280
and hit enter.

120
05:01.280 --> 05:03.600
So that is us for our validation challenge.

121
05:03.600 --> 05:06.960
I hope it's been informative for you and I'd like to thank you for viewing.
