Using Ansible Modules to Manage Scheduled Tasks in Your Environment

15 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Cron jobs are a tool that help admins automate things. The downside is that configuring them across hundreds of systems is a daunting task. Ansible has a module to help here as well. This lab will help you understand how that module is configured.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Write a Playbook to Create a Weekly YUM Update Job in Cron

Your playbook entry for this job should look similar to this:

  - cron:
     name: "Weekly YUM Update"
     special_time: weekly
     job: "/usr/bin/yum update -y"
Write a Playbook to Execute /usr/bin/status on Reboot

This section of your playbook should look like this:

  - cron:
     name: "Reboot Status"
     special_time: reboot
     job: "/usr/bin/status"
Write a Playbook to Execute /usr/bin/faillock_report at the Required Time

This section of the playbook should look like this:

  - cron:
     name: "Faillock Report"
     job: /usr/bin/faillock_report
     weekday: "1,3,5"
     minute: "30"
     hour: "7"

Additional Resources

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

Recently the security was breached on the webservers in our environment. One of the postmortem findings was that the breached servers were not up to date with current security patches. Because of this, we've been tasked with writing a playbook that sets up three cron jobs, and then running the playbook on every server in our environment. These are the three cron jobs:

  1. Running yum update weekly
  2. Executes /usr/bin/status upon reboot:
    • This command will check in with your monitoring system and give a current status of critical services and their package versions.
  3. Running /usr/bin/faillock_report at 7:30AM on Mondays, Wednesdays, and Fridays (to report excessive login attempts)

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.

Sign In
Welcome Back!

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

Get Started
Who’s going to be learning?