- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud
- Security
Increasing Ansible Security
Being able to use Ansible to secure your nodes is an in-demand skill, and understanding how to use playbooks for security is excellent knowledge to have. This value is shown by the fact that it is one of the objectives of the *Red Hat Certified Ansible Specialist* exam. In this hands-on lab, we will make use of the various modules to help secure your nodes in a reproducible manner. This hands-on lab is not meant to be an exhaustive example of security; instead it showcases ways to enhance your nodes security. **Note:** Ansible has been set up and configured for use on the Control server and two nodes. This will save you time when doing the hands-on lab. *This course is not approved or sponsored by Red Hat.*
Lab Info
Table of Contents
-
Challenge
Log in to the Ansible Control Node Server and Change to the `ansible` User
-
Sign in to the Ansible Control Node server using the
cloud_usercredentials, and change to theansibleuser. -
Test that Ansible is working:
ansible all -m pingNote: It may take several minutes after the start of the lab, for the test to work as expected.
-
-
Challenge
Use an Ad Hoc Ansible Command to Check the Uptime on All the Nodes
-
Show the uptime on all the servers:
ansible all -a /usr/bin/uptime
-
-
Challenge
Create a Playbook Called `selinux-check.yml`and Ensure SELinux Is Enabled on All Nodes
-
Use the
selinuxmodule and create a playbook calledselinux-check.yml:vim selinux-check.yml -
Check the playbook, ensuring all the nodes have
SELinuxinstalled and that it's set to enabled on all nodes.
Note: More information about the
selinuxmodule can be found here: https://docs.ansible.com/ansible/latest/modules/selinux_module.html -
-
Challenge
Test the Playbook `selinux-check.yml` to Ensure It Works
-
Test the playbook
selinux-check.ymlagainst all the nodes and ensure there are no errors:ansible-playbook selinux-check.yml
-
-
Challenge
Create a Playbook Called `firewalld.yml` and Verify the Installation of `firewalld`
- Use the
firewalldmodule (and any other modules as required) in a playbook calledfirewalld.ymlto ensurefirewalldis installed, enabled, and started on all the nodes.
Note: More information about the
firewalldmodule can be found here: https://docs.ansible.com/ansible/latest/modules/firewalld_module.html?highlight=firewalld - Use the
-
Challenge
Test the `firewalld.yml` Playbook and Verify Task Completion
-
Test the playbook and ensure that
firewalldis installed, enabled, and started on each of the nodes:sudo systemctl status firewalld
-
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.