nerdexam
Red_HatRed_Hat

EX294 · Question #11

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

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

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

Question

11. Modifying File Content Create a playbook named /home/greg/ansible/issue.yml according to the following instructions: - This playbook will run on all inventory hosts. - The playbook will replace the content of /etc/issue with a single line of text as shown below: - On hosts in the dev host group, this line of text will display as: Development - On hosts in the test host group, this line of text will display as: Test - On hosts in the prod host group, this line of text will display as: Production Correct Answer: See the below explanation Explanation Explanation/Reference: Solution: [greg@control ansible]$ ansible dev -m debug -a 'var=inventory_hostname' [greg@control ansible]$ ansible dev -m debug -a 'var=groups' [greg@control ansible]$ ansible dev -m debug -a 'var=groups.dev' [greg@control ansible]$ ansible-doc copy [greg@control ansible]$ ansible-doc stat [greg@control ansible]$ vim /home/greg/ansible/issue.yml --- - name: modify file hosts: all tasks: - name: Content 1 ansible.builtin.copy: content: 'Development' dest: /etc/issue when: inventory_hostname in groups.dev - name: Content 2 ansible.builtin.copy: content: 'Test' dest: /etc/issue when: inventory_hostname in groups.test - name: Content 3 ansible.builtin.copy: content: 'Production' dest: /etc/issue when: inventory_hostname in groups.prod [greg@control ansible]$ ansible-navigator run issue.yml -m stdout # Verification (mandatory operation) [greg@control ansible]$ ansible dev -a 'cat /etc/issue' [greg@control ansible]$ ansible test -a 'cat /etc/issue' [greg@control ansible]$ ansible prod -a 'cat /etc/issue' This playbook will run on managed nodes in the dev host group. Create a directory /webdev with the following requirements: Owner is webdev group. Regular permissions: Owner: read+write+execute, Group: read+write+execute, Other: read+execute Special permissions: Set Group ID Create a symbolic link /var/www/html/webdev pointing to /webdev Create a file /webdev/index.html with a single-line content as shown below: Development Correct Answer: See the below explanation Explanation Explanation/Reference: Solution: [greg@control ansible]$ ansible-doc file [greg@control ansible]$ ansible-doc copy [greg@control ansible]$ ansible dev -a 'ls -ldZ /var/www/html' -rw-r--r--. 1 root root system_u:object_r:`httpd_sys_content_t`:s0 11 Apr 14 07:11 /var/www/html [greg@control ansible]$ vim /home/greg/ansible/webcontent.yml - name: Create Web Directory hosts: dev roles: - apache tasks: - name: Create directory ansible.builtin.file: path: /webdev state: directory group: webdev mode: '2775' - name: Create link ansible.builtin.file: src: /webdev dest: /var/www/html/webdev state: link - name: Copy content ansible.builtin.copy: content: 'Development' dest: /webdev/index.html setype: httpd_sys_content_t [greg@control ansible]$ ansible-navigator run webcontent.yml -m stdout

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

#Playbooks#Conditionals#File Management#Host Groups
Full EX294 PracticeBrowse All EX294 Questions