Working with Confidential Data in Ansible

30 minutes
  • 4 Learning Objectives

About this Hands-on Lab

The Red Hat Certified Ansible Specialist Exam (EX407) requires an understanding of working with confidential data within Ansible. This hands-on lab goes over how you can use the `ansible-vault` command to encrypt sensitive files within a vault file and also how to work with those vault files in an Ansible playbook. The exercise assumes basic proficiency with several common ansible modules and general ansible playbook use. Upon completing the lab, you will have developed an improved understanding of `ansible-vault` and vault files.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Encrypt `/home/ansible/secret` using the `ansible-vault` command.
  • Run ansible-vault encrypt /home/ansible/secret and provide a simple password of your choosing.
  • Be sure to remember the password!
Create */home/ansible/vault* as a vault password file that may be used to access the encrypted secret file without prompt.
  • Run the command echo "<Your_Vault_Password>" > /home/ansible/vault.
  • Substitute <<Your_Vault_Password>Your_Vault_Password> with the password you chose in the previous task.
Run the playbook */home/ansible/secPage.yml* using your *vault* password file to validate your work.
  • Run the command ansible-playbook --vault-password-file /home/ansible/vault /home/ansible/secPage.yml.
  • If your encryption was configured correctly, you should get no errors.
Verify that the secure page deployed correctly by attempting to access http://node1/secure/classified.html as the user *bond* with the password *james*.
  • Run curl -u bond http://node1/secure/classified.html and supply the password james when prompted.
  • The command should return the contents of classified.html regarding the weather in a certain city.

Additional Resources

In an effort to improve security, you have been tasked with securing an Ansible variable file. The variable file is to be used in an ansible job that creates a secure website. To do this, complete the following:

  1. Encrypt the file /home/ansible/secret using ansible-vault.
  2. Then configure a vault password file named /home/ansible/vault to be used to run the Ansible playbook /home/ansible/secPage.yml successfully with the encrypted secrets file.
  3. Verify your work by running the secPage.yml playbook using ansible-playbook and specifying your vault password file.
  4. Test that the site deployed correctly by trying to access http://node1/secure/classified.html using the user bond with the password james.

Summary tasks list:

  • Encrypt home/ansible/secret using the ansible-vault command.
  • Create /home/ansible/vault as a vault password file that may be used to access the encrypted secret file without prompt.
  • Run the playbook /home/ansible/secPage.yml using your vault password file to validate your work.
  • Verify that the secure page deployed correctly by attempting to access http://node1/secure/classified.html as the user bond with the password james.

Important notes:

  • For your convenience, Ansible has been installed on the control node.
  • /home/ansible/secPage.yml provides several examples of how to use various key ansible modules. It is worth looking at, but it should not require modification.
  • The user ansible is already on all servers with the appropriate shared keys for access to all necessary servers from the control node.
  • The ansible user also has sudo access with no password. It has the same password as cloud_user.
  • All necessary Ansible inventories have been created for you.
What are Hands-on Labs

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.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!
Thanks for reaching out!

You’ll hear from us shortly. In the meantime, why not check out what our customers have to say about ACG?