EX294 · Question #3
EX294 Question #3: Real Exam Question with Answer & Explanation
Sign in or unlock EX294 to reveal the answer and full explanation for question #3. The question stem and answer options stay visible for context.
Question
03. Installing Software Packages Create a playbook named /home/greg/ansible/packages.yml: - Install the php and mariadb packages on hosts within the dev, test, and prod host groups. - Install the RPM Development Tools package group on hosts within the dev host group. - Update all packages on hosts within the dev host group to the latest version. Correct Answer: See the below explanation Explanation Explanation/Reference: Solution: [Virtual Machine: 172.25.250.254|control] [greg@control ansible]$ ansible-doc -l | grep yum [greg@control ansible]$ ansible-doc yum [greg@control ansible]$ vim /home/greg/ansible/packages.yml --- - name: install1 hosts: dev,test,prod tasks: - name: install packages hosts: dev tasks: - name: install group ansible.builtin.yum: name: "@RPM Development Tools" state: present - name: upgrade all packages ansible.builtin.yum: name: "*" state: latest # Verification: Confirm correctness of the task by checking software installation. (mandatory operation) [greg@control ansible]$ ansible-navigator run packages.yml -m stdout [greg@control ansible]$ ansible dev,test,prod -a 'rpm -q php mariadb' [greg@control ansible]$ ansible dev -a 'yum grouplist' ... Installed Groups: RPM Development Tools [greg@control ansible]$ ansible dev -a 'yum update' ... Nothing to do. 04. Using RHEL System Roles Utilize RHEL system roles by installing the RHEL system roles software package and create a playbook /home/greg/ansible/selinux.yml that meets the following conditions: - Run on all managed nodes. - Use the selinux role. - Configure this role to set the selinux on managed nodes to enforcing. Correct Answer: See the below explanation Explanation Explanation/Reference: Solution: [Virtual Machine: 172.25.250.254|control] # Install rhel-system-roles [greg@control ansible]$ sudo yum -y install rhel-system-roles [greg@control ansible]$ ansible-galaxy list # Specify the location of roles [greg@control ansible]$ vim ansible.cfg ... # additional paths to search for roles in, `colon` separated roles_path = /home/greg/ansible/roles:/usr/share/ansible/roles # View roles [greg@control ansible]$ ansible-galaxy list # Copy an existing example file to use [greg@control ansible]$ cp /usr/share/doc/rhel-system-roles/selinux/exampleselinux-playbook.yml /home/greg/ansible/selinux.yml [greg@control ansible]$ vim /home/greg/ansible/selinux.yml Delete operations:23,30d :9,19d --- - hosts: all vars: selinux_policy: targeted selinux_state: enforcing # prepare prerequisites which are used in this playbook tasks: - name: execute the role and catch errors block: - include_role: name: rhel-system-roles.selinux rescue: # Fail if failed for a different reason than selinux_reboot_required. - name: handle errors fail: msg: "role failed" when: not selinux_reboot_required - name: restart managed host shell: sleep 2 && shutdown -r now "Ansible updates triggered" async: 1 poll: 0 ignore_errors: true - name: wait for managed host to come back wait_for_connection: delay: 10 timeout: 300 - name: reapply the role include_role: name: rhel-system-roles.selinux # Use ansible-playbook to execute roles installed via rpm package. # Use ansible-navigator to execute roles installed via collections. [greg@control ansible]$ ansible all -m shell -a 'grep ^SELINUX=/etc/selinux/config; getenforce' node2 | CHANGED | rc=0 >> SELINUX=enforcing Enforcing node4 | CHANGED | rc=0 >> SELINUX=enforcing Enforcing node5 | CHANGED | rc=0 >> SELINUX=enforcing Enforcing node3 | CHANGED | rc=0 >> SELINUX=enforcing Enforcing node1 | CHANGED | rc=0 >> SELINUX=enforcing Enforcing
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.