
Certification Training for EX374 Exam Dumps Test Engine [2026]
Jun 04, 2026 Step by Step Guide to Prepare for EX374 Exam
NEW QUESTION # 126
Write a playbook to use the lookup plugin to retrieve a secret from a file.
Answer:
Explanation:
- name: Retrieve secret hosts: localhost tasks:
- name: Get secret set_fact:
secret: "{{ lookup('file', '/etc/secret.key') }}"
- debug:
var: secret
Explanation:
Using lookup with the file plugin securely retrieves sensitive information from external files.
NEW QUESTION # 127
Delete the local branch feature-enhancement after merging it into main.
Answer:
Explanation:
git branch -d feature-enhancement
Explanation:
Deleting a branch cleans up unused branches after their changes are merged or become unnecessary.
NEW QUESTION # 128
Set up notifications for job failures in Automation Controller.
Answer:
Explanation:
1. Navigate to Notifications and click Add.
2. Choose Type: Slack.
3. Configure Slack details and associate it with a job template.
4. Set the trigger to On Failure.
Explanation:
Notifications improve responsiveness by alerting users of job failures in real time.
NEW QUESTION # 129
Extract all unique keys from a dictionary using a filter.
Answer:
Explanation:
- name: Extract dictionary keys hosts: localhost
vars:
my_dict: name: John age: 30 city: London
tasks:
- name: Get keys debug:
var: "{{ my_dict.keys() | list }}"
Explanation:
Extracting dictionary keys helps in scenarios requiring iteration or analysis of available attributes.
NEW QUESTION # 130
Securely rotate SSH keys for inventory hosts.
Answer:
Explanation:
1. Generate new keys:
ssh-keygen -t rsa -f ~/.ssh/new_key
2. Update the ansible_ssh_private_key_file in the inventory.
Explanation:
Regularly rotating SSH keys improves security and ensures continued access control.
NEW QUESTION # 131
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 # 132
Create a playbook to stop execution after encountering an error in any task.
Answer:
Explanation:
- name: Stop on error hosts: all
tasks:
- name: Intentional failure
command: exit 1
ignore_errors: no
Explanation:
By default, Ansible stops on errors unless ignore_errors is set to yes. This ensures errors are addressed before proceeding.
NEW QUESTION # 133
Write a playbook to display all variables assigned to a host.
Answer:
Explanation:
- name: Display all variables hosts: web1
tasks:
- debug:
var: hostvars[inventory_hostname]
Explanation:
The hostvars dictionary allows access to all variables defined for a specific host, useful for debugging or validation.
NEW QUESTION # 134
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 # 135
Loop through a YAML dictionary to display keys and their values.
Answer:
Explanation:
- name: Display dictionary items hosts: localhost
vars:
services: nginx: enabled mysql: disabled
tasks:
- name: Display each service status debug:
msg: "Service {{ item.key }} is {{ item.value }}" with_dict: "{{ services }}"
Explanation:
with_dict simplifies iterating over key-value pairs in YAML dictionaries, making it ideal for processing complex configurations.
NEW QUESTION # 136
Test machine credentials for AWS EC2 hosts.
Answer:
Explanation:
ansible all -m ping -i aws_ec2.yml --key-file ~/.ssh/aws_key.pem
Explanation:
Testing machine credentials ensures they work correctly for authenticating cloud-managed hosts.
NEW QUESTION # 137
Pull the EE image from the private container registry.
Answer:
Explanation:
podman pull registry.example.com/my_execution_env:1.0
Explanation:
Pulling the image retrieves the EE from the registry, making it available locally for use in automation tasks.
NEW QUESTION # 138
Use lookup with with_items to iterate over multiple external files.
Answer:
Explanation:
- name: Read multiple files hosts: localhost
tasks:
- name: Fetch file contents debug:
msg: "{{ lookup('file', item) }}" with_items:
- /tmp/file1.txt
- /tmp/file2.txt
Explanation:
Combining lookup with with_items iterates over multiple sources, enabling batch processing of external data.
NEW QUESTION # 139
Create a custom configuration for the EE in Automation Controller.
Answer:
Explanation:
1. Navigate to Execution Environments in the Automation Controller.
2. Add a new EE entry:
o Name: Custom EE
o Image: registry.example.com/my_execution_env:1.0
3. Associate the EE with a project or job template.
Explanation:
Customizing EEs in Automation Controller allows for task-specific runtime environments.
NEW QUESTION # 140
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 # 141
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 # 142
Validate if a string matches a specific regular expression.
Answer:
Explanation:
- name: Validate string hosts: localhost vars:
text: "ansible_123" tasks:
- name: Check format fail:
msg: "String format invalid"
when: not text is match('^ansible_[0-9]+$')
Explanation:
The match filter evaluates whether a string adheres to a regex pattern, enforcing data consistency.
NEW QUESTION # 143
Verify that an EE supports a specific Ansible version.
Answer:
Explanation:
podman run --rm my_execution_env:1.0 ansible --version
Explanation:
Checking the Ansible version inside the EE ensures compatibility with playbooks and modules requiring specific versions.
NEW QUESTION # 144
Extract all IP addresses from a list containing mixed data using a filter.
Answer:
Explanation:
- name: Filter IP addresses hosts: localhost
vars:
mixed_data: ["192.168.1.1", "hello", "10.0.0.2", "world"] tasks:
- name: Extract IPs debug:
var: "{{ mixed_data | select('ipaddr') | list }}"
Explanation:
The select filter with ipaddr identifies and extracts valid IP addresses from a mixed data list.
NEW QUESTION # 145
Install a collection from Ansible Galaxy using the requirements.yml file.
Answer:
Explanation:
# requirements.yml
collections:
- name: ansible.posix
version: 1.3.0
ansible-galaxy collection install -r requirements.yml
Explanation:
The requirements.yml file defines dependencies, and the install command ensures the specified collections are downloaded and available.
NEW QUESTION # 146
Verify the directory structure of an existing collection.
Answer:
Explanation:
tree ~/.ansible/collections/ansible_collections/my_namespace/my_collection
Explanation:
The tree command provides a visual representation of the collection structure, ensuring proper organization.
NEW QUESTION # 147
Verify if Automation Controller can access a private registry.
Answer:
Explanation:
1. Add container registry credentials.
2. Test by pulling an EE image for a job template.
Explanation:
Testing ensures Automation Controller can authenticate and fetch images securely from private registries.
NEW QUESTION # 148
You need to check the current configuration settings of your Git environment. Display them.
Answer:
Explanation:
git config --list
Explanation:
Viewing configuration settings verifies the global and repository-specific settings for consistency.
NEW QUESTION # 149
Create a playbook to find all IP addresses in a text file.
Answer:
Explanation:
- name: Extract IP addresses hosts: localhost
tasks:
- name: Read file and extract IPs set_fact:
ip_list: "{{ lookup('file', '/tmp/ips.txt') | regex_findall('\b(?:\d{1,3}\.){3}\d{1,3}\b') }}"
- debug:
var: ip_list
Explanation:
Using regex_findall, this playbook extracts all IP addresses from a file, enabling network data parsing.
NEW QUESTION # 150
......
Ultimate Guide to Prepare EX374 Certification Exam for Red Hat Certified Specialist: https://www.test4cram.com/EX374_real-exam-dumps.html
Red Hat Certified Specialist EX374 Real Exam Questions and Answers FREE Updated: https://drive.google.com/open?id=1onoFS3KzVZ0j_G3z1wlluOc71tXT5a5U