Using Ansible Modules to Manage Archiving in Your Environment

15 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Dealing with compressed files is one of the less glamorous things that a System Administrator is called upon to do. Fortunately, Ansible has modules to help work with archived files as well. This lab will help cement those skills.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Unpack the /root/file.tar.gz Tarball into /opt on DBServer1

Your playbook should look similar to:

- name: Copy data dev stuff and inflate data and dev stuff
  hosts: dbservers
  become: yes

  tasks:
  - unarchive:
     src: /root/file.tar.gz
     dest: /opt/
Unpack the devstuff Tarball into /opt on dbserver1

This part of your playbook should look similar to:

- unarchive:
   src: /tmp/devstuff.tar.gz
   dest: /opt/
   remote_src: yes
Compress and Copy /var/log/messages from dbserver1 to the Ansible Host

The last part of your playbook should look like this:

  - archive:
     path: /var/log/messages
     dest: /tmp/messages.tar.gz

  - fetch:
     src: /tmp/messages.tar.gz
     dest: /tmp/

Additional Resources

Notice: Ansible is installed as the root user, so please work on all tasks after elevating to the root user.

We've gotten a ticket from the DBA team that says they need a couple of tarballs unpacked on the DB server. One is on the Ansible Host, /root/file.tar.gz, while the other is /tmp/devstuff.tar.gz on the DB Server. Both need to be extracted into /opt on the DB Server.

We have another ticket requesting that we compress /var/log/messages on the DB server and put the result in /tmp on the Ansible host. We've decided to do both tasks at once.

We need to write a playbook that will unpack all of the mentioned tarballs, compress /var/log/messages on DBServer1, and then get that tarball into /tmp on the Ansible Host.

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?