Using Packer and Ansible for Hardening

1 hour
  • 2 Learning Objectives

About this Hands-on Lab

This lab facilitates learning by doing by utilizing Packer to create an AMI file that is staged in Amazon AWS. The Packer tool is used to run an Ansible role against the OS image to harden the image. The resulting AMI would then be available to specify when creating or upgrading Kubernetes clusters using installers such as kops.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Grab the AWS Keys and Install the Ansible Role
  1. Verify the files in your home directory.

  2. Verify that Ansible is installed.

  3. Display the AWS credentials for your lab and copy to the clipboard for later use.

    IMPORTANT: DO NOT STORE THESE KEYS ANYWHERE BUT ON YOUR PRIVATE CLIENT SYSTEM.

  4. Generate an RSA key for use by the Ansible playbook to harden the OS system.

  5. Hit Enter on the configuration prompts to save the RSA key to the default directory.

  6. Create a default vpc for your lab instance.

  7. Use the anisible-galaxy script to install the sample playbook we will use in this lab.

Add the Keys to the Packer Script and Run the Packer Job
  1. Edit the ksac-packer-build.sh file and paste in the previously copied AWS credentials as environmental variables.

  2. Save and exit the file.

  3. Execute the Packer build.

  4. Once provisioned, log into the AWS Management Console to view the created AMIs using the lab credentials provided.

  5. Navigate to the EC2 dashboard.

  6. On the left menu, select Instances. Packer Builder now has an instance state of terminated.

  7. On the left menu under Images, select AMIs. The newly created ksac-ubuntu-hard image now appears.

Additional Resources

This lab installs Ansible and Packer on the bastion host. Basic Linux commands are used to run a Packer job that has been preconfigured.

The student should be familiar with Linux commands and able to edit shell scripts.

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!

Psst…this one if you’ve been moved to ACG!