
Achive your Success with Latest RedHat EX374 Exam [Jun 06, 2026]
The EX374 Exam Test For Brief Preparation
NEW QUESTION # 135
Split a string into a list of words using a filter.
Answer:
Explanation:
- name: Split string hosts: localhost vars:
sentence: "Ansible is powerful" tasks:
- name: Split words debug:
var: "{{ sentence | split(' ') }}"
Explanation:
The split filter divides a string into a list based on a delimiter, enabling flexible text processing.
NEW QUESTION # 136
Extract the filename from a file path using filters.
Answer:
Explanation:
- name: Extract filename hosts: localhost
vars:
file_path: "/tmp/example.txt" tasks:
- name: Get filename debug:
var: "{{ file_path | basename }}"
Explanation:
The basename filter retrieves the filename from a given path, streamlining file manipulations.
NEW QUESTION # 137
Write a test playbook to call the custom module hello.py.
Answer:
Explanation:
# test_hello.yml
- name: Test custom module hosts: localhost
tasks:
- name: Call hello module
my_namespace.my_collection.hello:
Explanation:
Testing custom modules ensures their proper implementation and usability within the collection.
NEW QUESTION # 138
Test the machine credentials by connecting to a host.
Answer:
Explanation:
ansible all -m ping -i inventory.yml --vault-password-file vault_pass.txt
Explanation:
Testing ensures the machine credentials can authenticate and connect to the managed hosts successfully.
NEW QUESTION # 139
Check if a variable is a list and fail if it is not.
Answer:
Explanation:
- name: Validate list hosts: localhost
vars:
data: [1, 2, 3]
tasks:
- name: Ensure variable is a list fail:
msg: "Variable is not a list" when: data is not list
Explanation:
The is list filter ensures the data type matches expectations, preventing runtime errors.
NEW QUESTION # 140
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 # 141
Check if all elements in a list are unique.
Answer:
Explanation:
- name: Validate unique list hosts: localhost
vars:
items: [1, 2, 3, 4, 5] tasks:
- name: Ensure uniqueness
fail:
msg: "List contains duplicates"
when: items | length != items | unique | length
Explanation:
By comparing the length of the original and deduplicated list, this check ensures all elements are unique.
NEW QUESTION # 142
Use a delegated task to add a DNS entry for a host.
Answer:
Explanation:
- name: Add DNS entry hosts: web1
tasks:
- name: Update DNS records
command: echo "web1 IN A 192.168.1.10" >> /etc/dns/zone.file
delegate_to: dns_server
Explanation:
Delegating DNS management tasks to a specific server ensures centralized and consistent DNS configuration.
NEW QUESTION # 143
Create a project in Automation Controller to pull content from a private Git repository using an SSH key.
Answer:
Explanation:
1. Navigate to Credentials and add: o Type: Source Control
o Username: Leave blank
o SSH Private Key: Upload your private key.
2. Create a project:
o Source Control Type: Git
o URL: [email protected]:private/repo.git
o Credential: Select the SSH credential.
3. Sync the project.
Explanation:
Using an SSH key allows secure access to private repositories for pulling automation content.
NEW QUESTION # 144
Run a playbook in Automation Controller using an execution environment (EE).
Answer:
Explanation:
1. Go to Execution Environments.
2. Add a new EE with the image: registry.example.com/my_execution_env:1.0.
3. Assign the EE to a job template and run the playbook.
Explanation:
Execution environments ensure consistent runtime environments for playbook execution.
NEW QUESTION # 145
Run a playbook from the Git project in Automation Controller.
Answer:
Explanation:
1. Create a Job Template: o Name: Run Git Playbook o Project: Git Project
o Playbook: site.yml
o Inventory: Add an appropriate inventory.
2. Save and launch the job.
Explanation:
Job templates tie playbooks to inventories and credentials, enabling consistent and repeatable automation execution.
NEW QUESTION # 146
Uninstall a collection from your local environment.
Answer:
Explanation:
ansible-galaxy collection remove my_namespace.my_collection
Explanation:
Removing unnecessary collections keeps the Ansible environment clean and avoids conflicts.
NEW QUESTION # 147
Set up multiple environment inventories (dev and prod) with shared group variables.
Answer:
Explanation:
mkdir -p dev prod
echo "[web_servers]" > dev/inventory.ini
echo "web1 ansible_host=192.168.1.10" >> dev/inventory.ini echo "[web_servers]" > prod/inventory.ini
echo "web1 ansible_host=10.0.0.1" >> prod/inventory.ini
Explanation:
Separate inventories for environments ensure isolation and simplify management of environment-specific configurations.
NEW QUESTION # 148
List all available EEs in the Automation Controller.
Answer:
Explanation:
1. Log in to Automation Controller.
2. Navigate to Execution Environments to view all registered EEs.
Explanation:
Viewing the list of EEs helps administrators track available environments and their configurations.
NEW QUESTION # 149
Create an advanced workflow template in Automation Controller.
Answer:
Explanation:
1. Go to Templates and create a Workflow Template.
2. Add multiple job templates in a sequential or conditional order.
Explanation:
Workflow templates orchestrate complex automation sequences, enabling multi-step operations in a single execution.
NEW QUESTION # 150
Push the EE image to a private container registry.
Answer:
Explanation:
podman tag my_execution_env:1.0 registry.example.com/my_execution_env:1.0 podman push registry.example.com/my_execution_env:1.0
Explanation:
Pushing the EE image to a container registry enables distribution and reuse across different environments or teams.
NEW QUESTION # 151
Create a playbook to override the default inventory SSH port by using a special variable at runtime.
Answer:
Explanation:
# playbook.yml
- name: Test connection with overridden SSH port hosts: web1
tasks:
- ping:
Execution:
ansible-playbook -i inventory.yml playbook.yml -e "ansible_port=2022"
Explanation:
Passing ansible_port as an extra variable ensures runtime overrides without altering the inventory.
NEW QUESTION # 152
Merge multiple dictionaries into one using the combine filter.
Answer:
Explanation:
- name: Merge dictionaries hosts: localhost
vars:
dict1:
key1: value1 dict2:
key2: value2
dict3:
key3: value3
tasks:
- name: Combine dictionaries debug:
var: "{{ dict1 | combine(dict2) | combine(dict3) }}"
Explanation:
The combine filter simplifies merging multiple dictionaries into a single, unified structure.
NEW QUESTION # 153
Create a project in Automation Controller to pull playbooks from a Git repository.
Answer:
Explanation:
1. Go to Projects in Automation Controller.
2. Click Add.
3. Fill in:
o Name: Git Project
o Source Control Type: Git
o Source Control URL: https://github.com/example/repo.git
4. Save and sync the project.
Explanation:
Creating a project from Git ensures that playbooks and configurations are version-controlled and automatically synchronized.
NEW QUESTION # 154
Retrieve data from a YAML file using lookup.
Answer:
Explanation:
# data.yml app: myapp
version: 1.0
- name: Load YAML data hosts: localhost
tasks:
- name: Fetch data set_fact:
app_data: "{{ lookup('file', 'data.yml') | from_yaml }}"
- debug:
var: app_data
Explanation:
The from_yaml filter converts YAML content into a usable dictionary, integrating external configurations into playbooks.
NEW QUESTION # 155
Use failed_when to define custom failure conditions for a task.
Answer:
Explanation:
- name: Custom failure hosts: all
tasks:
- name: Fail if output is not 'success'
command: echo "fail"
register: output
failed_when: "'success' not in output.stdout"
Explanation:
The failed_when directive enables fine-grained control over failure conditions, improving playbook robustness.
NEW QUESTION # 156
Use delegation to restart a service on a specific host (db1) from a different host.
Answer:
Explanation:
- name: Restart service on db1 hosts: web1
tasks:
- name: Restart nginx service:
name: nginx
state: restarted delegate_to: db1
Explanation:
Delegating service management to another host ensures targeted actions on infrastructure components.
NEW QUESTION # 157
You are given access to a Git repository with the URL https://github.com/example/repo.git. Clone the repository to your local machine in the directory /home/user/projects.
Answer:
Explanation:
cd /home/user/projects
git clone https://github.com/example/repo.git
Explanation:
Cloning a repository retrieves all files, branches, and history to your local system. The git clone command initiates this process by downloading the specified repository.
NEW QUESTION # 158
......
Revolutionary Guide To Exam RedHat Dumps: https://www.realexamfree.com/EX374-real-exam-dumps.html
Pass EX374 Exam Latest Practice Questions: https://drive.google.com/open?id=1lj9D9TylTgZuFhVop5XfH4ZPXOqpLHe7

