EX294 Red Hat Certified Engineer RHCE – Using Scripts for System Administration Tasks

  • By
  • January 19, 2023
0 Comment

1. Introduction

Hello. Welcome to section One. Using scripts for system administration tasks till now, we already learnt how to write ansible playbooks and how to use ansible ad hoc commands. In this section, we learn how we can use ansible ad hoc commands to run as shell script.

In fact, we will be doing nothing extra than we have learned so far. We’ll just put ansible ad hoc commands inside a file to run them as shell script. This is something important for you to know. Let’s move ahead with the first task of this section.

2. Task: Creating File and Symbolic Link Using Shell Script

Hello, welcome to this lecture. In this lecture we will learn how we can create file and symbolic link for the file using ansible ad hoc commands inside shell script. Here is task description. Create a script file dot sh to run ansible ad hoc commands for the following task tasks create one file results own pro nodes on this specific path so here we need to keep in mind we must create this specific path before we create this file. This is prerequisite configure full permissions at group level and read executions for others set markers user and group owner. We know how we can do this we’ll use honor and group directives with file module create symbolic link in root directory with default name so we’ll create symbolic link for this file in root directory default name means symbolic link will be named as results. Here are contents of our shell script we’ll create file with name file dot sh we’ll put three ansible ad hoc commands inside this file we will be using file module for all these commands.

With first command we’ll create this directory path which is prerequisite here we must use state set to directory and also we need to use become flag because we are going to create this directory path under root directory and we need root privileges with second command. We’ll create file with name results on this directory path and we’ll set permissions for group and others as per task requirements. We also need to set file owner as Mark and also group owner as Mark. Here state must be touch because we need to create zero length file on this directory path again we need to use Become. Then using this command we will be creating symbolic link for this file result file on this specific path and this is a destination this is a link name. We need to create symbolic link under rhode directory with the same name as that of file name which is default name.

So by default symbolic link is created with the same name as that of file. Even if we don’t specify this file name here state must be set to link to create symbolic link then become flagged to use root privileges we’ll save and quit. Then we need to execute this script as an symbol user. So first of all we must provide execution permissions on this script so here using this command we can provide execution permissions to all we can also restrict execution permissions only to user by using u plus x. Then we need to execute this script using this syntax dot forward slash then skip name. We know why we use this. If we don’t use dot forward slash the system will not able to find this script so you must use dot to run the script. Now let’s move to the ensable control node and start doing this task. Now we are on an ensable control node and I am logged in as ensable user here under tasks directory we need to create file with name file dot she here we need to put our ansible ad hoc commands I will change to insert mode ensable target is prod mode as per task description m to specify module A. To provide arguments we need to create directory path state must be set to directory become so this is all for first command. Next anceible probe again we need to use file material using dasha will provide arguments here we need to provide path of the file to be created.

Then using mode will configure permissions we know how to do this. For the group we need to provide full permissions and for others we need to provide read and execution permissions we need to set owner as mark user is already created on all remote nodes so we don’t need to worry about this. To set the group owner we’ll use group darktave then finally we’ll set straight to touch become third command ansible prode again we’ll use file module here we need to use SRC directive to specify source file for which we want to create symbolic link. So this is the source file dust. We need to create symbolic link under root directory with default name, which is results. Then important here is we must set state to link. We’ve already gone through documentation of file module. And we know all this become this is all we need to do I will save and quit now next step is to provide execution permissions to the script this is something you must keep in mind. Because by default file you create with extension dot she never has execution permissions. So here we can see this we’ll use chmode.

I will provide execution permissions to everyone you can provide permissions according to task requirements. The next step is to execute this script. So it will take few seconds this is completed and here we can see for these two tasks state is set to link. So these are tasks to create symbolic link. So here we have tasks to create results file and to set user owner group owner and to configure permissions so these first two tasks are to create directory path. So this is clear from the outcome of ansible control node. Now to verify we know we can use ansible ad hoc commands I will clear the screen. We’ll execute ansible then protein which is target.

We will be using default module which is command module using a option we’ll specify command to be executed. I will list attribute of this file using LS l here we must use Become here we have output we can see file has been created on the pro nodes and user and group owners are set to mark also at group level full permissions are configured and four others read and execution permissions are configured. Now again I will execute same command but this time I will list contents of root directory here we have output here we can see symbolic link has been created for this file with the name results under root directory for both pro nodes m host one and Most two. This is over. About this task.

3. Task: Creating User and Assigning supplementary Group Using Shell Script

Hello, welcome to this lecture. In this lecture we learn how we can create user and how we can assign supplementary group to user. Here is task description create a script user sh to run and see the ad hoc commands for the following tasks create user with username name RHCE own all manage nodes and set password as RHCE underscore pass use encryption sha five one, two we know how to use it.

Create group with name ex 294 and assign the supplementary group to this user. Use user IDs 2021 here we have contents of our script. We’ll create file with name user dot sh as per task requirement using first ansible ad hoc command will create group with name ex two nine four using group module this is prerequisite because we need to create group first only then we can assign this group to some user. Then using second and simple ad hoc command will create user. Here we need to use user module username is RHCE using password directly will set password. Here we know we need to use Ginger to filter password underscore hash to encrypt the password.

And this is the algorithm we need to use. Here you must keep in mind you must enclose this password RSE underscore path in single quotation marks. So in case you are using variable, you don’t need to enclose the variable. But here we are using value of the password. So here we must enclose this. Then using groups directive will assign this supplementary group to this user. So here you must keep in mind you must use groups in case you will use group it will not fail because group is also valid directive and is used to assign primary group. So this is something you must keep in mind. Then using UID will specify user ID become we’ll save this file and create the next.

We need to assign execution permissions on this script. Then we’ll execute this script. Let’s move to the ensuite control node and start doing this task. Now we are on ensable control node and I am logged in as ansible user. Here under Tasks directory will create file with name user dot sh as per task requirement I will change to insert mode. And here we’ll specify ensible ad hoc commands. Ansible all we need to execute these commands on all manage nodes. M to specify module we need to use group module to create group using dash A will specify arguments name of group to be created. Then I will set state to present. Although this is deferred behavior, I would always prefer to specify it. Become the second addo command to create user ansible all m we need to use user module a to specify arguments username is RHCE using password directly will set password. Here we need to use ginger two expression password we need to set RHCE underscore pass.

This must be enclosed in single quotation marks. Then using PY filter will specify Ginger to filter password underscore hash to encrypt the password, we know how to use it. Then we’ll use groups directive to assign supplementary group. So here you must keep in mind you are using groups, because group is also valid directive. Then using UID, we’ll specify user ID to be used. And finally I will set state to present. We must use dash dash become with these commands. Because we need root per villages to execute them. This is all we need to do. For this, I will save and create now. Next we need to assign execution permissions on this script. Execution permissions are provided to everyone. Now I will execute the script. It can take some time. It’s completed. Here we can see user with user ID two, zero, twenty one and username RSE has been created.

Supplementary group ex 294 has been assigned to this user. On the top, you will find first four task to create group. So we can see group ex 294 was created successfully. This is all for this task. Now, to verify, we’ll execute ensable ad hoc commands ansible all. I will display password file and I will grab for user RSCE. Here we can see entry for RSCE user in past WD file on each managed node. To be more clear, I will remove this filter. So now it’s more clear. So this is entry on m host three. This is entry on m host two. In similar way, you can verify for m host four and am host one.

Now I will clear the screen again. I will execute this command. But this time I will display shadow file. Here we must use Become, because to display this file, we need root privileges. Here we have output. Here we can see entry for RSE user. This is password in encrypted format. This is output tone Mhost one. In similar way, we can change for m host three, m host two and m host four. This is all about.

Comments
* The most recent comment are at the top

Interesting posts

Preparing for Juniper Networks JNCIA-Junos Exam: Key Topics and Mock Exam Resources

So, you’ve decided to take the plunge and go for the Juniper Networks JNCIA-Junos certification, huh? Great choice! This certification serves as a robust foundation for anyone aiming to build a career in networking. However, preparing for the exam can be a daunting task. The good news is that this guide covers the key topics… Read More »

Mastering Microsoft Azure Fundamentals AZ-900: Essential Study Materials

Ever wondered how businesses run these days without giant server rooms? That’s the magic of cloud computing, and Microsoft Azure is a leading cloud platform. Thinking about a career in this exciting field? If so, mastering the Microsoft Certified: Azure Fundamentals certification through passing the AZ-900 exam is the perfect starting point for you. This… Read More »

The Impact of Remote Work on IT Certification Exam Processes

With remote work becoming the new norm, it’s not just our daily routines that have changed but also how we tackle IT certification exams. Gone are the days of trekking to testing centers; now, your living room can double as an exam room. This shift has brought about some fascinating changes and challenges. Let’s dive… Read More »

IT Risk Management: CRISC Certification Exam Essentials

Do you ever feel like the IT world is moving at warp speed? New tech seems to pop up every day, leaving you wondering how to keep up and truly stand out in your field. Companies are increasingly concerned about online threats, data leaks, and meeting legal requirements. That’s where the CRISC (Certified in Risk… Read More »

The Ultimate Guide to Mastering Marketing Automation for Email Wizards

Hey there, email aficionados! Welcome to your new favorite read – the one that’s going to turbocharge your email marketing game. You’re about to dive into the captivating world of marketing automation, a place where efficiency meets effectiveness, letting you boost your campaigns without breaking a sweat. Get ready to discover how automation can not… Read More »

Master YouTube Marketing with These 10 Powerful Steps

Welcome to the dynamic world of YouTube marketing! Whether you’re a seasoned pro or just getting started, harnessing the power of YouTube can significantly boost your brand’s visibility and engagement. With over 2 billion monthly active users, YouTube offers a vast audience for your content. But how do you stand out in such a crowded… Read More »

sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |