Unit 3 Lab
Making and Using Inventories
Note
If you are unable to finish the lab in the ProLUG lab environment we ask you reboot
the machine from the command line so that other students will have the intended environment.
Resources / Important Links
Required Materials
- Lab Server Killercoda recommended
- Rocky 9.6+ - ProLUG Lab
- Or comparable Linux box
rootorsudocommand access
Downloads
The lab has been provided for convenience below:
Pre-Lab (Lab Setup)
If you're not doing the lab on Killercoda, make sure to follow the setup guide below.
ProLUG Lab Setup
If you're using the ProLUG lab environment, run the following commands.
| prolug-lab-setup | |
|---|---|
Personal Lab Setup
Alternatively, for your own lab environment, clone down the necessary files from GitHub.
| lab-setup | |
|---|---|
Lab 🧪
This lab is designed to have the engineer verify and execute their automation tools to interact with the OS in a controlled fashion.
If you do the killercoda Lab 3, just answer these questions. If you are doing the lab in the ProLUG environment, find the scripts in /labs/automation/unit3.
If you are doing the lab in the ProLUG environment, find the scripts
in /labs/automation/unit3.
Bash execution
-
Execute script u3_script.sh and see if you can read the data
- What values are shown?
-
What does the script look like in bash?
- Could you modify this script to hit a different API endpoint and place the file in a different location?
-
Read the provided users.csv file
-
Parse out the data for just the first and the third fields
- Could you parse out only the first and second fields?
- Can you remove the header?
-
Regenerate the data for /root/users.csv
Python execution
-
Run the u3_script.py and look at what it shows you.
- What are you shown?
-
Inspect the file and see if you can figure out what it was doing.
- Note: Modify with vi or vim. Can you make this show the lowest 10 items, ordered by magnitude?
- Can you generate a python script that parses the /root/users.csv file? (What resources might you use to do this?)
Ansible execution
-
Run the u3_script.yml and look at what it shows you.
- What are you shown?
- Can you modify this output so show other interesting parts of the API calls?
- If you had to pull a specific field, could you do it
Again, you don't know how data might come to you in your organization, so this is an exercise in parsing things different ways.
-
Inspect your current inventory files.
- What file type are these? (https://docs.ansible.com/ansible/latest/inventory_guide/intro_inventory.html)?
- What other file types might you use for inventories?
- Do you have a preference on how the data are formatted, or where the variables are located on these?
- Do you think some of this looks better formatted or do you prefer it as yaml?
-
Check the yaml versions of these files.
This is a very high level review of the many ansible-inventory commands. It is recommended that you parse and play with these files more, as the concepts will continue to be built on in later labs.
Note
If you are unable to finish the lab in the ProLUG lab environment we ask you reboot
the machine from the command line so that other students will have the intended environment.