Red Hat Certified Engineer RHCE · Free Practice Question Medium

Question 18

You are managing a role that installs security patches but want to ensure that the patches are only applied during a maintenance window. How would you use Ansible's scheduling features or cron within a role to ensure that patches are installed at the specified time?

  • A

    Applying Patches During a Maintenance Window Using Cron in a Role
    In the role's tasks/main.yml, schedule patch installation using cron:

    This ensures patches are applied during a specified maintenance window (e.g., 2 AM).

  • B

    This is a performance based question and not multiple choice.  Therefore the answer is in #1.  If you require additional explanation, please ask your question in the Q&A section.

Reveal correct answer

Correct answer: A

A.

This solution demonstrates how to use Ansible's cron module to schedule security patch installations during a specified maintenance window. In this example, the cron module is used within the role to schedule the execution of a playbook (patch_playbook.yml) at a specific time. The cron job is set to run at 2 AM by specifying the minute and hour (minute: "0" and hour: "2"), ensuring that the patches are applied during the desired maintenance window. The job field specifies the command to run, which is the Ansible playbook that installs the patches. By using this approach, you can automate patching during off-peak hours, ensuring minimal disruption.

Line-by-Line Explanation

  1. - name: Schedule security patch installation

    • This task is named "Schedule security patch installation," indicating that it is responsible for scheduling the patch installation using cron.

  2. ansible.builtin.cron:

    • This uses the cron module to create or manage cron jobs on the target systems.

  3. name: "Security Patching"

    • Specifies a descriptive name for the cron job. This helps to identify the job in the system's crontab.

  4. minute: "0"

    • Specifies that the cron job will run at minute 0 (i.e., at the start of the hour).

  5. hour: "2"

    • Specifies that the cron job will run at hour 2, which corresponds to 2 AM. This ensures that the patch installation occurs during the designated maintenance window.

  6. job: "/usr/bin/ansible-playbook /path/to/patch_playbook.yml"

    • Defines the command to be executed by cron. In this case, it runs the Ansible playbook patch_playbook.yml to apply the security patches.

  7. user: root

    • Specifies that the cron job should run as the root user, ensuring that the necessary permissions are available for patch installation.

By using Ansible's cron module, this approach automates the scheduling of security patch installations during a specified maintenance window, ensuring that patches are applied without manual intervention and at an optimal time.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need