Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Red Hat Certified Specialist in Services Management and Automation EX358 Exam Guide
Red Hat Certified Specialist in Services Management and Automation EX358 Exam Guide

Red Hat Certified Specialist in Services Management and Automation EX358 Exam Guide: Get your certification and prepare for real-world challenges as a Red Hat Certified Specialist

eBook
₹799 ₹2680.99
Paperback
₹3351.99
Subscription
Free Trial
Renews at ₹800p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Red Hat Certified Specialist in Services Management and Automation EX358 Exam Guide

Block Storage – Learning How to Provision Block Storage on Red Hat Enterprise Linux

Block storage within Red Hat Enterprise Linux (RHEL) makes up the foundation of many core applications. You will use it for many things within the world of Linux, from application development to backups to deployments of infrastructure such as OpenStack using Internet Small Computer Systems Interface (iSCSI). Through understanding how and when to use block storage over other storage options and how to provision it through manual steps as well as automate it through Ansible, you will be able to comprehend and grasp the knowledge needed for your day-to-day work with Linux as well as ensuring you understand the building blocks required to meet the needs of the EX358 exam. These lessons not only allow you to complete the EX358 exam with success but also enable you to better understand why we use block storage over other filesystems in situations that dictate the use of this filesystem type in real-world scenarios.

This comes in handy when you are building your infrastructure at your company, in your home lab for learning purposes, or for that start-up you always wanted to create. At the end of this chapter, you will be able to provision block storage using Red Hat best practices both manually and through Ansible automation in order to meet the requirements of Red Hat. This will allow you to gain support from Red Hat if you have an active contract and also gain help from the community if you do not have Red Hat support in order to resolve any issues you may run into during your usage of this technology.

You will be able to configure iSCSI initiators, boot with them both manually and through Ansible automation, and safely tear down unused variations of the iSCSI block storage after you are done with this chapter. This will, in turn, ensure your full understanding of the overall life cycle and the effective nature of block storage in your ecosystem.

In this chapter, we’re going to cover the following main topics:

  • iSCSI block storage—overview of what it is and why we need it
  • iSCSI block storage—manual provisioning and deployment
  • iSCSI block storage—Ansible automation playbook creation and usage

Technical requirements

Before we delve into the topics in detail, you will need to set a few things up. Let’s look at what they are.

Setting up GitHub access

You will need a free GitHub account in order to access some of the code that will be provided throughout this book. Please sign up for a free account at https://github.com/. We will be utilizing the code found in the following repository throughout the course of this book: https://github.com/PacktPublishing/Red-Hat-Certified-Specialist-in-Services-Management-and-Automation-EX358-. We will be utilizing the code snippets found in the ch1 folder of this code repository (aka repo) for our iSCSI automation hands-on exercises, which can be found here: https://github.com/PacktPublishing/Red-Hat-Certified-Specialist-in-Services-Management-and-Automation-EX358-Exam-Guide/tree/main/Chapter01. The code placed here will allow you to check your work and ensure you are on the right track when writing your playbooks within Ansible. Please keep in mind these are one person’s way of writing tested playbooks that will meet the exam objectives; however, there are many ways of writing successful playbooks to meet these objectives.

Setting up your lab environment

All of the demonstrations of VirtualBox and coding will be shown on macOS but can be performed on Windows as well as Linux OSs. We will be setting up some iSCSI block devices. First, you will need a machine that can run VirtualBox with enough memory to run your machine and three VMs that each have 2 GB of memory, one 10 GB hard drive, and one 5 GB hard drive, which equals 15 GB of required hard drive space per VM, as can be seen in the following screenshot:

Figure 1.1 – Layout of the VirtualBox deployment

Figure 1.1 – Layout of the VirtualBox deployment

This is mainly for the storage hands-on labs, and you can revert to one 10 GB hard drive for exercises. RHEL 8.1 requires at least 9.37 GB of space to run. Using a Red Hat Developer account (https://developers.redhat.com/), you can access real Red Hat software to develop your skills as well as the software in order to set this up:

Figure 1.2 – Signup is simple!

Figure 1.2 – Signup is simple!

Because the exam is set for RHEL 8.1, I recommend using this version for your studying needs in order to get the most authentic exam-like infrastructure possible. In the following screenshot, the correct version you should download is the first option:

Figure 1.3 – The correct version for the exam and for you

Figure 1.3 – The correct version for the exam and for you

This will be true for the entirety of the book, including the comprehensive review and lab at the end. Before installing the OS, you can create a second hard drive in VirtualBox from the settings, as can be seen in the following screenshot:

Figure 1.4 – Creating a second hard drive for your VM

Figure 1.4 – Creating a second hard drive for your VM

You also need to ensure that you choose Bridged Adapter mode for your network Attached to option. The Promiscuous Mode option is also allowed so that it can reach the internet and other adapters. One caveat to keep in mind is that bridged-over Wi-Fi does not always play nice, so try to ensure you have a wired connection if you are setting up your lab in this manner:

Figure 1.5 – Bridged adapter with Promiscuous Mode option

Figure 1.5 – Bridged adapter with Promiscuous Mode option

From here, you can then mount the downloaded ISO and kick off the installation:

Figure 1.6 – Mounting RHEL DVD ISO that was downloaded previously

Figure 1.6 – Mounting RHEL DVD ISO that was downloaded previously

There are some best practices you need to keep in mind. We will be installing the Server with the GUI option. Make sure to create yourself an administrator account as well as keeping your root account as you will want to do everything as sudo and not directly as root for security purposes and all-around good habits. The user creation screen, as follows, allows you to set up your root password and any users you would like to create:

Figure 1.7 – Administrator accounts are best practices; sudo over root is always preferred

Figure 1.7 – Administrator accounts are best practices; sudo over root is always preferred

Next, you will need to use the login for your Red Hat Developer account and license the VMs using the account credentials. See the following screenshot for how to correctly apply a Red Hat subscription license:

Figure 1.8 – Red Hat Developer credentials or an active Red Hat account needed

Figure 1.8 – Red Hat Developer credentials or an active Red Hat account needed

You can create one machine and then clone it into the other two you need. Make sure you choose to generate new MAC addresses and to make a full clone to ensure that no overlap causes network or storage issues, as shown in the following screenshot:

Figure 1.9 – Full clones with new MAC generation and a new name for the VM

Figure 1.9 – Full clones with new MAC generation and a new name for the VM

Next, we will set up the host file with the domain of example.com in order to route correctly to and from the different systems. You will need to do the following on the servers in a command line to get your IP addresses and then go to each device and set up the host file with the same information:

Figure 1.10 – Hostname and IP of rhel1.example.com system

Figure 1.10 – Hostname and IP of rhel1.example.com system

Next, let’s gather the hostnames or change them to what you would like them to be using the following commands and review the output in this case, which is rhel1.example.com:

[emcleroy@rhel1 ~]$ sudo hostnamectl set-hostname rhel1.example.com
[emcleroy@rhel1 ~]$ hostname
 rhel1.example.com

Use the hostnames and the IP addresses to build the inventory for the host file. After you do this, make sure that you shut down the system for it to save the changes permanently. Next, you’re going to want to add these as noted to the host file on all three VMs using the following command:

$ sudo vi /etc/hosts

Here is an example of the completed /etc/hosts file:

Figure 1.11 – Finished /etc/hosts file

Figure 1.11 – Finished /etc/hosts file

Keep in mind your /etc/hosts file will look different based on your IPs. You should now be able to ping via the hostname and IP of all of the different VMs from one to another:

Figure 1.12 – Example of working networking environment

Figure 1.12 – Example of working networking environment

Next, for ease of use, let’s set up passwordless sudo for our user account, which in my case would be emcleroy.

We will start by running the following command:

$ sudo visudo

Next, we will locate the lines of code highlighted in the following screenshot and add the highlighted lines of text. Also, note that if you are allowing administrators, you can simply uncomment # in front of the %wheel line as well:

Figure 1.13 – Highlighted lines of text to be added, substituting your username for mine

Figure 1.13 – Highlighted lines of text to be added, substituting your username for mine

You will need to do this for all three of the servers.

Finally, we will add SSH keys across the servers to allow for fast connectivity so that we do not have to type passwords every time we need to log in from one server to another. Start by generating SSH keys with the following command on your rhel1 VM:

$ ssh-keygen

Just leave the defaults and keep hitting Enter, and then once that is generated, you will want to do the following:

$ ssh-copy-id -i ~/.ssh/id_rsa.pub username@server

This will push the keys to the servers and allow all the servers to talk bi-directionally. You will want to do that for all three servers, so you will do the following (including for the server you are currently on to ensure that the keys are pushed to the known host file for all of the servers):

$ ssh-copy-id -i ~/.ssh/id_rsa.pub emcleroy@rhel1
$ ssh-copy-id -i ~/.ssh/id_rsa.pub emcleroy@rhel2
$ ssh-copy-id -i ~/.ssh/id_rsa.pub emcleroy@rhel3

From here, you have full access to a three-VM lab running RHEL 8.1 with secondary HDDs for use with this iSCSI hands-on exercise. The only minor differences will come up in the networking hands-on labs where we will go over adding additional network interface controllers (NICs) for network teaming. This will be another topic that you need to understand in order to ace the EX358 exam.

Congratulations! You have now successfully set up your lab environment. Pat yourself on the back and take a break. We will now be talking about the manual steps to build out iSCSI block devices and use them. This will be followed by putting that lab environment you just built to the test and getting hands-on experience with the technology.

iSCSI block storage – overview of what it is and why we need it

There are a number of things you need to know about block storage and, in this case, iSCSI. It is a storage area network (SAN) protocol that allows for devices or parts of devices to be seen as block storage by an end device. SAN is how iSCSI connects to the network and gives the ability to provide network logical unit numbers (LUNs). This allows systems to use these block devices as if they were physical hard drives in the system that they can boot from, save files to, or use like any hard drive that you have in your normal computer. With this in mind, we have to take a few things into account.

First, you have to ensure that your network can handle the connectivity without congestion as this will cause your systems to slow down and possibly lag behind what you are doing, causing users to become frustrated. Knowing this, you have to plan out your SAN extremely well and properly network out your block storage onto a normally non-encrypted network setup that meets the minimum speeds of 10 GB but can go much higher in a lot of cases. This allows smooth usage of your storage without the headaches you will run into as a system administrator. If you were to put this on the same network as your LAN traffic and expect your streaming (don’t do this while at work!) users are watching videos while trying to also do their jobs from a machine that is hosted from a SAN iSCSI block storage device. Other things to keep in mind are you need to ensure proper firewalld syntax is utilized and SELinux protocols are followed to allow connectivity at startup or you will have a giant paperweight without much happening.

There are some main items you have to take into account when you are looking at iSCSI using targetcli, and I will get to more details about targetcli as that is the toolset we will utilize to allow us to use iSCSI in our RHEL 8.1 environment. The main things you need to know are the initiator, target, Portal, LUN, Access Control List (ACL), and Target Portal Group (TPG). These items make up iSCSI storage and lead to a lot of misconceptions. Let’s test your knowledge before we dig deeper into the systems and how they work together to provide block storage over the network to remote servers.

Testing your knowledge

Answer the following questions:

  1. What is an iSCSI storage source on an iSCSI server?
    1. Target
    2. LUN
    3. iSCSI Qualified Name (IQN)
    4. ACL
  2. What is a unique worldwide name used to identify both initiators and targets?
    1. Target
    2. LUN
    3. IQN
    4. ACL
  3. An iSCSI client that is typically software-based is known as a:
    1. TPG
    2. Portal
    3. IQN
    4. Initiator
  4. Which of the following is an access restriction using the IQN?
    1. Target
    2. LUN
    3. IQN
    4. ACL
  5. What is the most commonly used software for setting up RHEL 8.1 iSCSI block storage?
    1. firewalld
    2. SELinux
    3. targetcli
    4. networkd
  6. Which service or port do you need to allow for iSCSI to work through your firewall?
    1. iSCSI-target
    2. 3260/UDP
    3. iSCSI
    4. targetcli
  7. What includes the named item 2020-06.com.mcleroy.www?
    1. Target
    2. LUN
    3. IQN
    4. ACL
  8. Which system do you need to enable to ensure iSCSI will start at boot?
    1. firewalld
    2. Target
    3. targetcli
    4. networkd

Answers:

  1. A. Target
  2. C. IQN
  3. D. Initiator
  4. D. ACL
  5. C. targetcli
  6. A.iSCSI-target
  7. C. IQN
  8. B. Target

iSCSI block storage – manual provisioning and deployment

We will start by installing targetcli and using that to set up iSCSI to provide block-based storage to other systems for file usage, boot systems, and so on. This will showcase the wide range of uses that come with iSCSI block storage implemented with RHEL 8.1. We will then show how to decommission the storage device and clean up the systems after utilizing the resources.

First, we will install targetcli in order to utilize the iSCSI systems on rhel1:

$ sudo dnf install targetcli -y

We will follow that by enabling the system to start up the iSCSI block storage. When the system boots or has an issue that causes the target system to need to restart, it will reload the service in order to keep the storage up and operational:

$ sudo systemctl enable target

After that, we will allow iscsi-initiator through firewalld in order to ensure that the other servers are able to access the block storage without issue. We will also reload the firewall, or the opening you just made will not be there:

$ sudo firewall-cmd --permanent --add-service=iscsi-target
$ sudo firewall-cmd –reload

After that, we will be utilizing the new service we just installed—targetcli—to create network block storage in order to share it with rhel2.example.com:

Figure 1.14 – targetcli initiated for the first time

Figure 1.14 – targetcli initiated for the first time

We will now create backstores for the physical disk partitioning. We will be creating backstores of the type block in order to meet the needs of the iSCSI system today. This will allow the persistent filesystems and us to set up how we would like the LUNs to be in terms of size and security:

/> cd /backstores/block
/backstores/block> create blockstorage1 /dev/sdb
Created block storage object blockstorage1 using /dev/sdb.

Next, we will create an IQN in the /iscsi directory in order to provide a target and destination for the block storage device:

/backstores/block> cd /iscsi
/iscsi> create iqn.2022-05.com.example:rhel1
Created target iqn.2022-05.com.example:rhel1.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi> ls
o- iscsi ..................................... [Targets: 1]
  o- iqn.2022-05.com.example:rhel1 .............. [TPGs: 1]
    o- tpg1 ........................ [no-gen-acls, no-auth]
      o- acls ................................... [ACLs: 0]
      o- luns ................................... [LUNs: 0]
      o- portals ............................. [Portals: 1]
        o- 0.0.0.0:3260 .............................. [OK]

As you can see in the preceding code snippet, a default portal was created on port 3260 for connectivity to the block storage backstores using the create command for the IQN. Next, we will create a LUN for physically supporting the storage needs of the iSCSI block storage:

/iscsi> cd /iscsi/iqn.2022-05.com.example:rhel1/tpg1/luns
/iscsi/iqn.20…sk1/tpg1/luns> create  /backstores/block/blockstorage1
Created LUN 0.

The next thing we need for iSCSI is an ACL to allow traffic to reach our storage devices successfully. We will need to exit out of targetcli temporarily to view the Red Hat name for the initiator’s IQN. It can be found in /etc/iscsi/initiatorname.iscsi:

Global pref auto_save_on_exit=true
Configuration saved to /etc/
[emcleroy@rhel1 ~]$ vi /etc/iscsi/initiatorname.iscsi

Here is an example of the initiator name that is currently being used on the next image:

Figure 1.15 – initiatorname.iscsi

Figure 1.15 – initiatorname.iscsi

We will go back into targetcli and finish up the system preparations, setting up the system to use an ACL of our choosing for the system that will be utilizing the block storage:

[emcleroy@rhel1 ~]$ sudo targetcli
targetcli shell version 2.1.53
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
> cd /iscsi/iqn.2022-05.com.example:rhel1/tpg1/acls
/iscsi/iqn.20...sk1/tpg1/acls> create iqn.2022-05.com.example:rhel2
Created Node ACL for iqn.2022-05.com.example:rhel2
Created mapped LUN 0.

Next, we will remove the default portal and create one on the specific IP address of our server:

> cd /iscsi/iqn.2022-05.com.example:rhel1/tpg1/portals
/iscsi/iqn.20.../tpg1/portals> delete 0.0.0.0 3260
Deleted network portal 0.0.0.0:3260
/iscsi/iqn.20.../tpg1/portals> create 192.168.1.198 3260
Using default IP port 3260
Created network portal 192.168.1.198:3260.

Finally, the following is your completed block storage target:

Figure 1.16 – iSCSI block storage target

Figure 1.16 – iSCSI block storage target

We have just shown how to provision iSCSI block storage for consumption. Now, we will showcase how to utilize that block storage for actual usage in your systems. We will connect from rhel1.example.com to rhel2.example.com and mount it, provision it, and utilize it to move and store files, as one of the examples of how we can use these systems is to increase the storage capacity of remote servers without needing to increase space, power, or cooling directly for the rack the server is housed within.

The first thing we will need to do is install the iSCSI utilities, as on the exam you may not have the installation of the Server with the GUI:

$ sudo dnf install iscsi-initiator-utils targetcli -y

This allows us to ingest the iSCSI block storage that we created previously. Next, we are going to look up the configured target on rhel1 (192.168.1.198) (please note: this might be a different IP for you in your lab) and log in to it to ensure connectivity. From here, we need to set the login information on the /etc/iscsi/iscsid.conf file in order to pass the correct login information so that we can log in to the storage device:

$ sudo getent hosts rhel1

Now, we will set the InitiatorName field so that we can pass a known entry to the connecting server using the following commands:

[emcleroy@rhel1 ~]$ sudo vi /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2022-05.com.example:rhel1
[emcleroy@rhel1 ~]$ sudo systemctl restart iscsid.service

Please note you can use the manual page to gain further insight into the iscsiadm command set with the man iscsiadm command. On rhel2, we will do a discovery of available block devices using the iscsiadm command. The –m flag specifies the mode—in this case, discovery. The –t flag specifies the type of target—in our case, st, which is sendtargets, which tells the server to send a list of iSCSI targets. The –p flag specifies which portal to use, which is a combination of IP address and port. If no port is passed, it will default to 3260:

[emcleroy@rhel2 ~]$ sudo iscsiadm -m discovery -t st -p 192.168.1.198:3260

Please note the output from the preceding command will be as follows:

 192.168.1.198:3260,1 iqn.2022-05.com.example:rhel1

As you can see here, we have a block device that is showing as available.

We will try to log in to the device, and you can see we have logged in and it is showing the device connected, as follows:

[emcleroy@rhel2 ~]$ sudo iscsiadm -m node -T iqn.2022-05.com.example:rhel1  -p 192.168.1.198 -l

In the preceding code, we are using the –m flag to choose node mode. We are using the –T flag to specify the target name. We are again using the –p flag for the portal, which defaults to port 3260. Finally, we are using the –l flag to tell iscsiadm to log in to the target.

Next, we are going to use the –m mode flag to check the session and –P to print the information level of 3:

[emcleroy@rhel2 ~]$ sudo iscsiadm -m session -P 3
iSCSI Transport Class version 2.0-870
version 6.2.1.4-1
Target: iqn.2022-05.com.example:rhel1 (non-flash)
     Current Portal: 192.168.1.198:3260,1
     Persistent Portal: 192.168.1.198:3260,1

You can see that we have sdb, which is the second drive on rhel2, and now we have sdc as well:

Figure 1.17 – sdc drive is now showing up

Figure 1.17 – sdc drive is now showing up

Next, we are going to partition the drive and format it with xfs. This will allow us to mount the system on boot as well as to save persistent files. This can be used for many things from file storage to OS or databases. First, we are going to format the drive to xfs:

[emcleroy@rhel2 ~]$ sudo mkfs.xfs /dev/sdc
meta-data=/dev/sdc               isize=512    agcount=4, agsize=327680 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=1310720, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

Then, we are going to use the following command to get the UUID to use in fstab to make it a persistent mount that will automatically mount at startup:

[emcleroy@rhel2 ~]$ lsblk -f /dev/sdc
NAME FSTYPE LABEL UUID                                 MOUNTPOINT
sdc  xfs          38505868-00de-4269-88d8-3357a22f2101
[emcleroy@rhel2 ~]$ sudo vi /etc/fstab

Here, we can see an example of the added value highlighted in fstab:

Figure 1.18 – Updated fstab after adding the iSCSI block storage device

Figure 1.18 – Updated fstab after adding the iSCSI block storage device

Here are the lines where we added the new iSCSI drive to fstab. Please note that for network devices, we pass the _netdev option. Next, we are going to mount the system in order to use it for moving files around:

[emcleroy@rhel2 ~]$ sudo mkdir -p /data
[emcleroy@rhel2 ~]$ sudo mount /data
[emcleroy@rhel2 ~]$ df /data
Filesystem     1K-blocks  Used Available Use% Mounted on
/dev/sdc         5232640 69616   5163024   2% /home/emcleroy/data
[emcleroy@rhel2 ~]$ cd /data

After it is mounted, we are going to move into the new drive, create a folder and a test .txt file, and ensure it saves, which it does by using the following commands:

[emcleroy@rhel2 ~]$ sudo mkdir test
[emcleroy@rhel2 ~]$ cd test/
[emcleroy@rhel2 ~]$ sudo vi test.txt

Next, we are going to remove the mount, log out of the connection, and delete the leftovers:

[emcleroy@rhel2 ~]$ cd
[emcleroy@rhel2 ~]$ sudo umount /data
[emcleroy@rhel2 ~]$ sudo iscsiadm -m node -T iqn.2022-05.com.example:rhel1 -p 192.168.1.198 -u
Logging out of session [sid: 8, target: iqn.2022-05.com.example:rhel1, portal: 192.168.1.198,3260]
Logout of [sid: 8, target: iqn.2022-05.com.example:rhel1, portal: 192.168.1.198,3260] successful.
[emcleroy@rhel2 ~]$ sudo iscsiadm -m node -T iqn.2022-05.com.example:rhel1 -p 192.168.1.198 -o delete

This wraps up the section on manually setting up iSCSI. Next is automating it. We will go into more detail in the hands-on review and the quiz at the end of the book. I hope you are enjoying this journey as much as I am.

iSCSI block storage – Ansible automation playbook creation and usage

We will start the automation portion of working with iSCSI block storage by first installing and configuring the use of Ansible core 2.9 as that is what is used in the EX358 exam. I will not be using the fully qualified collection name (FQCN) as that can sometimes cause errors in a 2.9 environment, which could lead to issues while taking the exam. This we want to avoid at all costs, so we will be using the classic module names, and I will explain the differences to a degree so that you can understand what you will need to use in future versions of Ansible.

First, let’s start by installing Ansible 2.9 on server rhel3 as that is going to be what we consider the workstation server from our yum repository. Depending on your personal preferences, you can make rhel1 your classroom server and rhel2 and rhel3 your test servers, but in our case, we have already set up rhel1 with iSCSI and rhel2.

First, we will enable the needed repos:

[emcleroy@rhel3 ~]$ sudo subscription-manager repos --enable ansible-2.9-for-rhel-8-x86_64-rpms
Repository 'ansible-2.9-for-rhel-8-x86_64-rpms' is enabled for this system.

Next, we will install Python 3:

[emcleroy@rhel3 ~]$ sudo dnf install python3 -y

Then, we will install Ansible 2.9:

[emcleroy@rhel3 ~]$ sudo dnf install ansible -y

Let’s check and ensure that the right version of Ansible is installed:

[emcleroy@rhel3 ~]$ ansible --version
ansible 2.9.27
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/emcleroy/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Oct 11 2019, 15:04:54) [GCC 8.3.1 20190507 (Red Hat 8.3.1-4)]

Next, we are going to start writing a playbook using the Yet Another Markup Language (YAML) Ansible language. This is a simple module-based function that will allow you to write up a playbook that will accomplish your task quickly and efficiently. I recommend a good editor when writing up these playbooks. JetBrains' PyCharm is my go-to and is what you will see me write my playbooks in when you see example screenshots of the finished results. Do also note that the finished playbooks can be found in the GitHub repository of this book, as mentioned in the Technical requirements section for each chapter.

The first thing you will want to create is a directory where you want to run the playbooks from:

[emcleroy@rhel3 ~]$ mkdir iscsi_mount

Once in the directory, we will create an inventory file with a default group that will have both the rhel1 and rhel2 servers in them:

[emcleroy@rhel3 ~]$ cd iscsi_mount
[emcleroy@rhel3 ~]$ vi inventory
[defaults]
rhel1 ansible_host=192.168.1.198
rhel2 ansible_host=192.168.1.133
[iscsi_block]
rhel1 ansible_host=192.168.1.198
[iscsi_user]
rhel2 ansible_host=192.168.1.133

As you can see, I added ansible_host and the IP address. This is in case there is no host file set up or the name is not DNS routable. I added the default group with all of the hosts, and there are two additional groups that allow me to limit what my playbooks make changes to. That way, I can tell my playbook to mount the storage on rhel2 using the iscsi_user group.

Next, we are going to write the block storage playbook named mount_iscsi.yml, and I will break it down after showing you what that playbook looks like:

---
- name: Ensure /data is mounted from rhel1 iSCSI target that was created manually onto rhel2
  hosts: iscsi_user
  become: true
  become_method: sudo
  tasks:
    - name: the targetcli package is installed
      yum:
        name: targetcli
        state: present
    - name: the IQN is set for the initiator
      template:
        dest: /etc/iscsi/initiatorname.iscsi
        src: templates/initiatorname.iscsi.j2
        mode: '644'
        owner: root
        group: root
    - name: Create mount directory for /data
      file:
        path: /data
        state: directory
        mode: '0755'
    - name: Restart iscsiadm
      command:
        cmd: systemctl restart iscsid.service
    - name: Mount new drive
      command:
  cmd: iscsiadm -m node –T iqn.2022-05.com.example:rhel1  -p 192.168.1.198 -l

The module name for this instance is yum, and that is used to install the iscsi-initiator-utils package that will install the utilities. Next, we have the different flags of the modules, such as dest: for the destination of the source file that is in your playbook’s templates folder. In the template folder location within your playbook directory, you will have the file/templates/initiatorname.iscsi.j2, which contains the initiator name to pass to the playbook. It will contain the following code:

InitiatorName=iqn.2022-05.com.example:rhel1

You can find out more about each module that you’re using by looking at the equivalent of a man page, as follows:

[emcleroy@rhel3 ~]$ ansible-doc yum

You can also list the files with the following command, but keep in mind there are thousands of modules, so try to grep the names if possible:

[emcleroy@rhel3 ~]$ ansible-doc –-list

The following screenshot shows what a normal ansible-doc page looks like for the different modules:

Figure 1.19 – Example of the yum module documentation page

Figure 1.19 – Example of the yum module documentation page

We will use the following command to run the ansible-playbook -i inventory mount_iscsi.yml -u emcleroy -k --ask-become –v playbook. This will be executed from the rhel3 server and make changes to the rhel2 server. This concludes our automated approach to mounting a LUN for iSCSI block storage. We learned a little about Ansible and how it works, from modules to templates. We will learn a lot more about Ansible and all of its inner workings in the upcoming chapters in greater detail, so stick around.

Summary

This brings us to the end of the first chapter, where we went into details about RHEL block storage, setting up a hands-on environment for testing purposes, and getting the first taste of Ansible. In the coming chapters, we will be digging deeper into how to use Ansible with further examples and more hands-on exercises that will help hone your abilities as a systems admin and help ensure you pass the EX358 exam. In the next chapter, we will be continuing our journey into network storage, talking about network file storage and how we can use that to share information across our organizations and make our jobs faster. Please join me as we continue our road to gaining the EX358 certification that you want to achieve and that I want to help you obtain.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Get the EX358 certification with this easy-to-follow guide while preparing for real-life challenges
  • Learn everything you need to know about Linux system administration and automation using Ansible 2.9
  • Use practical use cases and exam-focused questions to prepare for the certification exam

Description

If you’re ready to take the next step in your system engineering career with the EX358, then this book is for you. Packed with all the knowledge and skills that you need to configure and maintain services and applications on the Red Hat Linux 8 (RHEL OS 8) platform, this book will help you ace the exam and thrive at work. Red Hat Certified Specialist in Service Management and Automation will help you build a solid foundation of the most recent and up-to-date exam requirements and practice questions. Throughout the course of the book, you’ll get hands-on experience with different technical processes needed to fully administer a Red Hat Enterprise Linux 8 system. This will include file storage, database management, direct configuration of applications, such as SMB shares, networking. You’ll be well equipped with the configuration of essential components like firewall, SELinux, and iSCSI while learning how to automate these tasks using Ansible Automation 2.9 in order to alleviate the burden of completing them by hand. By the end of this book, you'll have covered all essential topics to ace the Red Hat EX358 certification exam and add another feather to your career as a Red Hat Certified Specialist.

Who is this book for?

This book is for you if you want to advance your career by adding the essential Red Hat certificate to your resume. It will be particularly useful for system administrators responsible for managing large enterprise environments, network services and Red Hat Certified Engineers interested in becoming a Red Hat Certified Architect (RHCA). Before reading this book, you must have a working knowledge of Red Hat Enterprise Linux and Ansible Automation and command line usage of Red Hat Enterprise Linux systems administration.

What you will learn

  • Attain the skills to take and pass the Red Hat EX358 certification exam
  • Become familiar with the ways of leveraging Ansible Core 2.9
  • Gain deeper knowledge of the Red Hat Linux Networking with DNS, DHCP, and IP addressing
  • Create your own link and master the networking domain through link aggregation creation
  • Set up printers and email services through Linux servers
  • Get up and running with MariaDB SQL databases
  • Explore how to create and control web traffic
Estimated delivery fee Deliver to India

Premium delivery 5 - 8 business days

₹630.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Feb 28, 2023
Length: 350 pages
Edition : 1st
Language : English
ISBN-13 : 9781803235493
Languages :
Concepts :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to India

Premium delivery 5 - 8 business days

₹630.95
(Includes tracking information)

Product Details

Publication date : Feb 28, 2023
Length: 350 pages
Edition : 1st
Language : English
ISBN-13 : 9781803235493
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
₹800 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
₹4500 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₹400 each
Feature tick icon Exclusive print discounts
₹5000 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just ₹400 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 10,799.97
Red Hat Enterprise Linux 9 Administration
₹3723.99
The Ultimate Docker Container Book
₹3723.99
Red Hat Certified Specialist in Services Management and Automation EX358 Exam Guide
₹3351.99
Total 10,799.97 Stars icon
Banner background image

Table of Contents

15 Chapters
Part 1: Red Hat Linux 8 –Configuring and Maintaining Storage with Automation Chevron down icon Chevron up icon
Chapter 1: Block Storage – Learning How to Provision Block Storage on Red Hat Enterprise Linux Chevron down icon Chevron up icon
Chapter 2: Network File Storage – Expanding Your Knowledge of How to Share Data Chevron down icon Chevron up icon
Part 2: Red Hat Linux 8 – Configuring and Maintaining Networking with Automation Chevron down icon Chevron up icon
Chapter 3: Network Services with Automation – Introduction to Red Hat Linux Networking Chevron down icon Chevron up icon
Chapter 4: Link Aggregation Creation – Creating Your Own Link and Mastering the Networking Domain Chevron down icon Chevron up icon
Chapter 5: DNS, DHCP, and IP Addressing – Gaining Deeper Knowledge of Red Hat Linux Networking Chevron down icon Chevron up icon
Part 3: Red Hat Linux 8 – Configuring and Maintaining Applications with Automation and a Comprehensive Review with Exam Tips Chevron down icon Chevron up icon
Chapter 6: Printer and Email – Setting Up Printers and Email Services on Linux Servers Chevron down icon Chevron up icon
Chapter 7: Databases – Setting Up and Working with MariaDB SQL Databases Chevron down icon Chevron up icon
Chapter 8: Web Servers and Web Traffic – Learning How to Create and Control Traffic Chevron down icon Chevron up icon
Chapter 9: Comprehensive Review and Test Exam Questions Chevron down icon Chevron up icon
Chapter 10: Tips and Tricks to Help with the Exam Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.9
(8 Ratings)
5 star 87.5%
4 star 12.5%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Thomas Aug 18, 2024
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Advanced topics
Subscriber review Packt
Michael Isaacs May 15, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Overall its a great read and clear to follow. The only section I had an issue with was the iscsi section. The Iscsi bit has some problems. The authors seem to not know which machine is the target and which is the initiator its an honest mix-up but shows up in the ansible too. Just keep this in mind. All other chapters are on point.
Amazon Verified review Amazon
Matt Apr 18, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book covers the complex concepts needed to prepare for the EX358 exam in a way that is very understandable. The concepts covered are also applicable in actual network and system management for many Server Admins and DevOps Engineers.The book does a great job of covering setup and configure many services, like web servers, traffic controllers, databases, shared storage, email services, etc. Many of these if first shows you how to configure them manually, and helps you get comfortable doing so. It then takes what you learned and shows how to use Ansible to automate the deployment so you can centralize it and perform it at scale.The examples and exercise are really helpful and there are sample code files available to download and work with to learn from.I haven’t completed the exam yet, but I am feeling way more confident after going through the activities in this book.
Amazon Verified review Amazon
Rilindo Foster Feb 28, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I have taken the EX358 exam back in 2021. At the time, there was no official material other than the rather expensive RHLS course, so I relied on the Red Hat documentation. When I was done, I told myself that I should write a book on the EX358.Then life happened, and I never got around to writing that book. Fortunately, somebody else did.This is the book that I would have written - you start with walking through how to deploy a service manually, then actual Ansible code to deploy said service. In addition, there is a "practice" exam at the end when you go through the tasks as if you are taking the exam.There are a few areas I would quibble about - I would have not started with iSCSI as the first topic and ipv6 coverage that was not fully explored (particularly over DHCP), but overall, it is a solid book. If you intend to: - Have a practical working knowledge of a wide set of services and configurations through Red Hat - Have a practical understanding of deploying said services and configurations via Ansible. - Being able to do both so that you can pass the Red Hat Certified Specialist in Services Management and Automation EX358 ExamThen get this book now. Give the author the money they deserve.
Amazon Verified review Amazon
new sound guy Jun 07, 2023
Full star icon Full star icon Full star icon Full star icon Full star icon 5
very easy to read and has tons of information for passing the exam. I recommend.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela