Red Hat Certified Engineer RHCE · Free Practice Question Medium
Question 10
Your organization requires a backup solution to archive log files from the /var/log directory of multiple servers daily and retain backups for 7 days. How would you use Ansible to automate the configuration of rsnapshot to meet this requirement?
-
A
- - hosts: all
- tasks:
- - name: Install rsnapshot
- ansible.builtin.yum:
- name: rsnapshot
- state: present
- - name: Configure rsnapshot
- ansible.builtin.template:
- src: rsnapshot.conf.j2
- dest: /etc/rsnapshot.conf
- - name: Schedule daily backups
- ansible.builtin.cron:
- name: "Daily log backup"
- minute: "0"
- hour: "2"
- job: "/usr/bin/rsnapshot daily"
This playbook automates daily backups of
/var/log, retaining them for 7 days. -
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 Ansible playbook automates the configuration of rsnapshot to create daily backups of the /var/log directory, retaining backups for 7 days. It ensures the required rsnapshot package is installed, configures rsnapshot using a template file, and schedules a daily cron job to run the backup process. By automating this setup, the playbook simplifies backup management and ensures consistency across multiple servers, providing a reliable solution for log file archiving and retention.
Line-by-Line Explanation
- - hosts: all
Specifies that the playbook should run on all managed nodes.
- tasks:
Defines the tasks to be executed in the playbook.
- - name: Install rsnapshot
Describes the task to install the rsnapshot package, which is used for managing backups.
- ansible.builtin.yum:
Uses the yum module to install the package on CentOS/RHEL systems.
- name: rsnapshot
Specifies the name of the package to install.
- state: present
Ensures the package is installed if not already present.
- - name: Configure rsnapshot
Describes the task to configure rsnapshot using a predefined template.
- ansible.builtin.template:
Uses the template module to copy and apply the configuration template for rsnapshot.
- src: rsnapshot.conf.j2
Specifies the source template file for the configuration.
- dest: /etc/rsnapshot.conf
Defines the destination path for the rsnapshot configuration file on the managed node.
- - name: Schedule daily backups
Describes the task to schedule a daily backup job using cron.
- ansible.builtin.cron:
Uses the cron module to create a cron job.
- name: "Daily log backup"
Provides a description for the cron job.
- minute: "0"
Specifies that the job should run at the start of the hour.
- hour: "2"
Schedules the job to run at 2:00 AM daily.
- job: "/usr/bin/rsnapshot daily"
Defines the command to execute the daily backup process.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
