nerdexam
Red_HatRed_Hat

EX294 · Question #13

EX294 Question #13: Real Exam Question with Answer & Explanation

Sign in or unlock EX294 to reveal the answer and full explanation for question #13. The question stem and answer options stay visible for context.

Submitted by kim_seoul· Apr 18, 2026Manage Variables, Facts, and Content

Question

13. Generating Hardware Report Create a playbook named /home/greg/ansible/hwreport.yml that will generate an output file /root/hwreport.txt containing the following information on all managed nodes: Inventory host name Total memory size in MB BIOS version Size of disk device vda Size of disk device vdb Each line in the output file should contain a key=value pair. Your playbook should: - Replace the placeholders in /root/hwreport.txt with the correct values. - If a hardware item does not exist, its related value should be set to NONE. Correct Answer: See the below explanation Explanation Explanation/Reference: Solution: [greg@control ansible]$ ansible all -m setup | grep mem [greg@control ansible]$ ansible all -m setup | grep bios [greg@control ansible]$ ansible all -m setup -a 'filter=*device*' [greg@control ansible]$ vim /home/greg/ansible/hwreport.yml --- - name: Hardware report hosts: all tasks: - name: Download hwreport ansible.builtin.get_url: dest: /root/hwreport.txt - name: Report 1 ansible.builtin.lineinfile: ansible.builtin.lineinfile: path: /root/hwreport.txt regexp: '^MEMORY=' line: MEMORY={{ ansible_memtotal_mb }} - name: Report 3 ansible.builtin.lineinfile: path: /root/hwreport.txt regexp: '^BIOS=' line: BIOS={{ ansible_bios_version }} - name: Report 4 ansible.builtin.lineinfile: path: /root/hwreport.txt regexp: '^DISK_SIZE_VDA=' line: DISK_SIZE_VDA={{ ansible_devices.vda.size }} - name: Report 5 ansible.builtin.lineinfile: path: /root/hwreport.txt regexp: '^DISK_SIZE_VDB=' line: DISK_SIZE_VDB={{ ansible_devices.vdb.size | default('NONE', true) }} # Verification: The collected reports should match the facts from each host. Please verify them manually. (mandatory operation) [greg@control ansible]$ ansible-navigator run hwreport.yml -m stdout [greg@control ansible]$ ansible all -a 'cat /root/hwreport.txt'

Unlock EX294 to see the answer

You've previewed enough free EX294 questions. Unlock EX294 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.

Topics

#Ansible Facts#Playbook Creation#File Manipulation#Jinja2 Filters
Full EX294 PracticeBrowse All EX294 Questions