Skip to content

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
  • Labs icon Lab
  • A Cloud Guru
Google Cloud Platform icon
Labs

Tackling Ansible Scheduling with the `at` Command

Being able to schedule tasks in Ansible is a valuable skill. This is shown by the fact that it is an objective of the *Red Hat Certified Ansible Specialist* exam. The `at` command and its associated commands (`atq` and `atrm`) can be used to schedule tasks in Linux-based systems or those that support the use of the `at` command. The `at` command is useful for scheduling one-time tasks. In this hands-on lab, we will make use of the `at` module to create scheduled tasks and show how to set and remove a task from the list of jobs. *This course is not approved or sponsored by Red Hat.*

Google Cloud Platform icon
Labs

Path Info

Level
Clock icon Intermediate
Duration
Clock icon 30m
Published
Clock icon Sep 13, 2019

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.

Table of Contents

  1. Challenge

    Log in to the Ansible Control Node Server and Change to the `ansible` User

    1. Sign in to the Ansible Control Node server using the cloud_user credentials, and change to the ansible user.

    2. Test that Ansible is working:

      ansible all -m ping
      

      Note: It may take several minutes after the start of the lab for the test to work as expected.

  2. Challenge

    Create and Run a Playbook Called `install-at.yml` that Installs, Enables, and Starts the `at` Service on All Nodes

    1. Create a playbook called install-at.yml that will install the at service on all nodes.
    2. Enable the atd service and start the service as part of the playbook.
    3. Run the playbook and ensure it installs, enables, and starts the service correctly.
  3. Challenge

    Create a Playbook Called `at-scheduled-task.yml` to Perform a Task on the Nodes in 20 Minutes

    1. Using the at module, create a playbook called at-scheduled-task.yml that adds a scheduled task to the nodes.
    2. The job should run in 20 minutes. The task to run is df -h > /tmp/diskspace.
  4. Challenge

    Run the `at-scheduled-task` Playbook and Test Each Node to Ensure the Task Is Scheduled

    1. Use the atq command to ensure the df -h task has been scheduled.
  5. Challenge

    Create a Playbook Called `remove-at-task.yml` to Remove the Previously Scheduled Task

    1. The remove-at-task.yml playbook should remove the task that was set in the at-scheduled-task.yml playbook.

    2. We can test with the atq command to ensure the task has been removed.

      Note: If they have not, we must troubleshoot why they have not been removed.

The Cloud Content team comprises subject matter experts hyper focused on services offered by the leading cloud vendors (AWS, GCP, and Azure), as well as cloud-related technologies such as Linux and DevOps. The team is thrilled to share their knowledge to help you build modern tech solutions from the ground up, secure and optimize your environments, and so much more!

What's a lab?

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.

Provided environment for hands-on practice

We will provide the credentials and environment necessary for you to practice right within your browser.

Guided walkthrough

Follow along with the author’s guided walkthrough and build something new in your provided environment!

Did you know?

On average, you retain 75% more of your learning if you get time for practice.

Start learning by doing today

View Plans