
Real RedHat EX374 Exam Questions Study Guide
Updated and Accurate EX374 Questions for passing the exam Quickly
NEW QUESTION # 138
Create a simple playbook to verify the webserver role within your collection.
Answer:
Explanation:
# test_playbook.yml
- name: Test webserver role hosts: localhost
roles:
- my_namespace.my_collection.roles.webserver
Explanation:
Playbooks referencing collection roles validate their functionality, ensuring roles are correctly structured and accessible.
NEW QUESTION # 139
Use a source control credential in a project in Automation Controller.
Answer:
Explanation:
1. Create a new project in Automation Controller.
2. Set the source type to Git.
3. Use the previously created source control credential.
4. Sync the project.
Explanation:
Integrating source control credentials with projects automates fetching playbooks and keeps configurations updated.
NEW QUESTION # 140
Build the execution environment image using Podman.
Answer:
Explanation:
cd my_execution_env
podman build -t my_execution_env:1.0 -f context/Dockerfile .
Explanation:
The podman build command creates a container image based on the Dockerfile, packaging all dependencies and configurations.
NEW QUESTION # 141
Control whether delegated facts are stored for the target host or the delegating host.
Answer:
Explanation:
- name: Delegate and control facts hosts: web1
tasks:
- name: Gather facts for db1 setup:
delegate_to: db1
delegate_facts: false
Explanation:
Setting delegate_facts: false stores gathered facts in the context of the delegating host rather than the target.
NEW QUESTION # 142
Configure a playbook to fail if the http_port variable is undefined for a host.
Answer:
Explanation:
- name: Check http_port hosts: web1
tasks:
- fail:
msg: "http_port is undefined"
when: http_port is not defined
Explanation:
Conditional checks prevent runtime errors by verifying required variables before task execution.
NEW QUESTION # 143
Schedule a playbook run in Automation Controller.
Answer:
Explanation:
1. Open a job template.
2. Click Schedules > Add.
3. Set the frequency and time for the playbook execution.
Explanation:
Scheduling automates recurring tasks, reducing manual intervention and ensuring consistency.
NEW QUESTION # 144
You need to revert the last commit on the main branch without removing the changes locally. Revert the commit.
Answer:
Explanation:
git revert HEAD
Explanation:
Reverting creates a new commit that undoes the changes made by the specified commit, maintaining the repository's integrity.
NEW QUESTION # 145
Perform a health check on db1 from web1.
Answer:
Explanation:
- name: Health check on db1 hosts: web1
tasks:
- name: Ping db1 ping: delegate_to: db1
Explanation:
Using the ping module with delegate_to, this task verifies the availability of db1 from web1.
NEW QUESTION # 146
Trigger a playbook run using the Automation Controller API.
Answer:
Explanation:
curl -X POST -H "Authorization: Bearer <token>" \
-d '{"inventory": 1, "job_template": 1}' \
https://controller.example.com/api/v2/job_templates/1/launch/
Explanation:
Using the API enables integration with external systems to trigger playbook executions programmatically.
NEW QUESTION # 147
Validate the EE configuration using Ansible Builder.
Answer:
Explanation:
ansible-builder validate --tag my_execution_env:1.0
Explanation:
The validate command checks the EE's configuration for errors, ensuring compatibility with Ansible's execution requirements.
NEW QUESTION # 148
Create a static inventory with groups web and db, each containing two hosts.
Answer:
Explanation:
# inventory.yml
web:
hosts:
web1:
ansible_host: 192.168.1.10 web2:
ansible_host: 192.168.1.11 db:
hosts:
db1:
ansible_host: 192.168.1.20 db2:
ansible_host: 192.168.1.21
Explanation:
A static inventory organizes hosts into groups for targeted playbook execution, enabling efficient host management.
NEW QUESTION # 149
Update an installed collection to the latest version.
Answer:
Explanation:
ansible-galaxy collection install my_namespace.my_collection --force
Explanation:
Using --force ensures the collection is reinstalled, fetching the latest version if available.
NEW QUESTION # 150
Configure web1 to use sudo for privilege escalation and run a playbook to display the hostname.
Answer:
Explanation:
echo "ansible_become: yes" > host_vars/web1.yml
Playbook:
- name: Check hostname hosts: web1
tasks:
- command: hostname
Explanation:
The ansible_become variable enables privilege escalation for tasks requiring elevated permissions.
NEW QUESTION # 151
Update an EE with new dependencies.
Answer:
Explanation:
1. Modify requirements.yml with additional dependencies.
2. Rebuild the EE:
ansible-builder build --tag my_execution_env:1.1
3. Push the updated EE:
podman push my_execution_env:1.1 registry.example.com/my_execution_env:1.1
Explanation:
Updating the EE ensures it includes the latest dependencies required by new playbooks or modules.
NEW QUESTION # 152
Validate the AWS inventory plugin.
Answer:
Explanation:
ansible-inventory -i aws_ec2.yml --list
Explanation:
Validating the plugin confirms it retrieves and parses data correctly from AWS.
NEW QUESTION # 153
Add documentation for your collection in a README.md file.
Answer:
Explanation:
echo "# My Collection
This is a custom Ansible collection." > my_namespace/my_collection/README.md
Explanation:
A README.md file provides essential details, such as usage and functionality, for users of the collection.
NEW QUESTION # 154
Integrate an EE with a specific project in Automation Controller.
Answer:
Explanation:
1. Go to Projects in Automation Controller.
2. Edit the project and assign the custom EE (registry.example.com/my_execution_env:1.0).
3. Save and test the integration with a Job Template.
Explanation:
Associating projects with specific EEs ensures tasks run in a controlled environment tailored to project requirements.
NEW QUESTION # 155
Validate if a given string ends with a specific suffix.
Answer:
Explanation:
- name: Validate string suffix hosts: localhost
vars:
filename: "document.txt" tasks:
- name: Check suffix fail:
msg: "File does not end with .txt" when: not filename.endswith(".txt")
Explanation:
The endswith method ensures filenames conform to expected extensions or formats.
NEW QUESTION # 156
Validate if a given variable contains a valid MAC address using a filter.
Answer:
Explanation:
- name: Validate MAC address hosts: localhost
vars:
mac_address: "00:1A:2B:3C:4D:5E" tasks:
- name: Check MAC validity fail:
msg: "Invalid MAC address" when: not mac_address | macaddr
Explanation:
The macaddr filter checks the validity of a MAC address, ensuring proper handling of network-related data.
NEW QUESTION # 157
Test the webserver role from the collection using ansible-playbook.
Answer:
Explanation:
ansible-playbook test_playbook.yml
Explanation:
Running a playbook verifies that the collection roles are functional and properly integrated.
NEW QUESTION # 158
......
Prepare Important Exam with EX374 Exam Dumps: https://www.pass4surequiz.com/EX374-exam-quiz.html
Download Real EX374 Exam Dumps for candidates. 100% Free Dump Files: https://drive.google.com/open?id=1lwXUvTQ30I3CwQC2v4FO8sHH9o582xQb