nerdexam
Red_HatRed_Hat

EX294 · Question #7

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

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

Submitted by andres_qro· Apr 18, 2026Work with Roles

Question

07. Creating and Using Roles Create a role named apache in /home/greg/ansible/roles according to the following requirements: - The httpd package is installed, set to start on system boot, and running. - Firewall is enabled and running, with rules allowing access to the web server. - A template file named index.html.j2 exists, used to create a file with the following output: /var/www/html/index.html: Welcome to HOSTNAME on IPADDRESS This playbook runs on hosts in the webservers host group and uses the apache role. Correct Answer: See the below explanation Explanation Explanation/Reference: Solution: [Virtual Machine: 172.25.250.254|control] [greg@control ansible]$ ansible-galaxy role init --init-path /home/greg/ansible/roles apache [greg@control ansible]$ ansible-galaxy list [greg@control ansible]$ vim roles/apache/tasks/main.yml --- - name: Install Apache ansible.builtin.yum: name: httpd state: latest - name: Start httpd ansible.builtin.systemd: name: httpd state: started enabled: yes - name: Start firewalld ansible.builtin.systemd: name: firewalld state: started enabled: yes - name: Start apache ansible.posix.firewalld: # Note that the service name for Apache in the firewall is not httpd. service: http permanent: yes state: enabled immediate: yes - template: # path = roles/apache/templates/ src: index.html.j2 dest: /var/www/html/index.html [greg@control ansible]$ vim roles/apache/templates/index.html.j2 Welcome to {{ ansible_nodename }} on {{ ansible_default_ipv4.address }} [greg@control ansible]$ vim /home/greg/ansible/apache.yml --- - name: webservers role hosts: webservers roles: - apache [greg@control ansible]$ ansible-navigator run apache.yml -m stdout [greg@control ansible]$ ansible webservers --list-hosts hosts (2): node3 node4 [Virtual Machine: foundation] # Verification (mandatory operation) # Verification: Access node3 and node4 to return webpage results (using command line or browser) to determine if the role is executed correctly. Welcome to node3.lab.example.com on 172.25.250.11 Welcome to node4.lab.example.com on 172.25.250.12

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 Roles#Service Management#Firewall Configuration#Jinja2 Templating
Full EX294 PracticeBrowse All EX294 Questions