Red Hat Certified Engineer RHCE · Free Practice Question Hard

Question 5

You are tasked with updating a list of configuration files across multiple managed nodes. How would you use the copy or template module in Ansible to deploy multiple configuration files, ensuring each file is placed in the correct directory?

  • A

    Deploying Multiple Configuration Files with Ansible
    To deploy multiple configuration files using the copy or template module:

    This deploys multiple config files to the correct directories on managed nodes.

  • 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 demonstrates how to deploy multiple configuration files to managed nodes using the copy module. The playbook leverages a loop to iterate through a list of source and destination file paths, ensuring each configuration file is copied to its designated location on the target systems. This approach ensures consistency, reduces redundancy, and simplifies the management of configuration files across multiple nodes.

Line-by-Line Explanation:

  1. Define Target Hosts:

    • Applies the playbook to all nodes in the inventory.

  2. Define Task Name:

    • Provides a descriptive name for the task.

  3. Use copy Module:

    • ansible.builtin.copy: Uses the copy module to copy files from the control node to the managed nodes.

    • src: "{{ item.src }}": Specifies the source file path dynamically from the loop.

    • dest: "{{ item.dest }}": Specifies the destination path dynamically from the loop.

  4. Define Files with loop:

    • loop: Iterates through a list of source (src) and destination (dest) file mappings.

    • src: Path to the source file on the control node.

    • dest: Target path where the file should be placed on the managed nodes.

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