Skip to content

Unit 2 Lab

Interacting with the Operating System

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 2, just answer these questions.

If you are doing the lab in the ProLUG environment, find the scripts in /labs/automation/unit2.

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.

Required Materials

  • Lab Server (Killercoda recommended)
    • Rocky 9.4+ - ProLUG Lab
    • Or comparable Linux box
  • root or sudo command access

Downloads

The lab has been provided for convenience below: - u2_lab.txt - u2_lab.md

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
1
2
3
4
cd /root
cp -r /labs/automation/unit2/* /root
chmod 755 /root/*.sh
chmod 755 /root/*.py

Personal Lab Setup

Alternatively, for your own lab environment, clone down the necessary files from GitHub.

lab-setup
1
2
3
cd /root
git clone https://github.com/het-tanis/prolug-labs.git
cp prolug-labs/AutomationLabs/Unit2_Interacting_with_OS/assets/* /root

Lab 🧪

In this lab, we will go through the process of executing our automation tools.

Bash Execution

  1. Run the u2_script1.sh and look at what it shows you.

    /root/u2_script1.sh
    

    • What are you shown?
  2. Inspect the file and see if you can modify it to show the first 15 lines.

    cat /root/u2_script1.sh
    

    • Note

      Modify with vi or vim. You may have to RTFM to continue.
  3. Run the u2_script2.sh and look at what it shows you.

    /root/u2_script2.sh
    

    • What happened in the script?
    • Did it work correctly?
      ls -l /root
      
  4. Inspect the file and see if you can make it use a different date format. You may have to read the man pages for date command.

    cat /root/u2_script2.sh
    

As you're interacting with the OS, are there any observations you have about how the scripts are set up, their structure and their output.

  • Is there anything you would add for your scripts?

  • If you would add something, how does it improve the code?


Python Execution

  1. Run the u2_script1.py and look at what it shows you.

    /root/u2_script1.py
    

    • What are you shown?
  2. Inspect the file and see if you can modify it to show the first and last 15 lines.

    cat /root/u2_script1.py
    

    • Note

      Modify with vi or vim. You may have to RTFM to continue.
  3. Run the u2_script2.py and look at what it shows you.

    /root/u2_script2.py
    

    • What are you shown?
  4. Inspect the file and see if you can make it use a different user shell, maybe one you've seen from other output in this lab.

    cat /root/u2_script2.py
    

    • Note

      Modify with vi or vim. You may have to RTFM to continue.

As you're interacting with the OS, are there any observations you have about how the scripts are set up, their structure and their output.

  • Is there anything you would add for your scripts?

  • If you would add something, how does it improve the code?


Ansible Execution

  1. Run the u2_script1.yml and look at what it shows you.

    ansible-playbook /root/u2_script1.yml
    

    • What are you shown?
  2. Inspect the file and see if you can modify it to show the first and last 15 lines.

    cat /root/u2_script1.yml
    

    • Note

      Modify with vi or vim. You may have to RTFM to continue.
  3. Run the u2_script2.yml and look at what it shows you.

    ansible-playbook /root/u2_script2.yml
    

    • What are you shown?
  4. Inspect the file and see if you can make it name the file differently or populate different content.

    cat /root/u2_script2.yml
    

    • Note

      Modify with vi or vim. You may have to RTFM to continue.
  5. Do one final ls -l against the /root directory. What is a difference between the .sh, .py, and .yml files?

    ls -l
    

As you're interacting with the OS, are there any observations you have about how the scripts are set up, their structure and their output.

  • Is there anything you would add for your scripts?

  • If you would add something, how does it improve the code?


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.