RedHat Red Hat Certified Specialist in Developing Automation with Ansible Automation Platform - EX374 FREE EXAM DUMPS QUESTIONS & ANSWERS

Configure a private registry in Automation Controller to fetch EEs.
Correct Answer:
1. Navigate to Settings > Registries in the Automation Controller.
2. Add a new registry:
o Name: Private Registry
o URL: registry.example.com
o Authentication: Provide credentials.
3. Save the configuration and test connectivity.
Explanation:
Adding a private registry allows Automation Controller to securely fetch and use custom EEs.
Convert a CSV file into a dictionary using the lookup plugin.
Correct Answer:
- name: Convert CSV to dictionary hosts: localhost
tasks:
- name: Read CSV set_fact:
csv_data: "{{ lookup('csvfile', '/tmp/data.csv', delimiter=',') }}"
- debug:
var: csv_data
Explanation:
The csvfile lookup plugin converts CSV data into dictionaries, integrating tabular data into playbooks.
Test machine credentials for AWS EC2 hosts.
Correct Answer:
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.
Test if the EE has all required collections installed.
Correct Answer:
podman run --rm my_execution_env:1.0 ansible-galaxy collection list
Explanation:
Listing installed collections verifies the EE contains the specified dependencies for playbook execution.
Apply the stashed changes back to the feature-update branch.
Correct Answer:
git stash apply
Explanation:
Applying a stash retrieves the saved changes, allowing them to be continued from the stored state.
Fetch the latest updates from the remote repository without merging them.
Correct Answer:
git fetch origin
Explanation:
Fetching updates the local metadata with remote changes without altering the working directory or branches.
Fetch a file from a managed node to the control node using delegation.
Correct Answer:
- name: Fetch file to control node hosts: web1
tasks:
- name: Retrieve file fetch:
src: /var/log/example.log
dest: /tmp/example.log
flat: yes
delegate_to: localhost
Explanation:
The fetch module retrieves files from a managed node to the control node, useful for collecting logs or artifacts.
Configure a playbook to fail if the http_port variable is undefined for a host.
Correct Answer:
- 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.
Test the webserver role from the collection using ansible-playbook.
Correct Answer:
ansible-playbook test_playbook.yml
Explanation:
Running a playbook verifies that the collection roles are functional and properly integrated.
Create a playbook to use query to retrieve a specific key-value pair from a JSON file.
Correct Answer:
# sample.json
{
"app": "web",
"version": "1.2.3"
}
- name: Query JSON file hosts: localhost tasks:
- name: Fetch app version
set_fact:
app_version: "{{ lookup('file', 'sample.json') | from_json | dict2items | selectattr('key', 'equalto', 'version') | map(attribute='value') | first }}"
- debug:
var: app_version
Explanation:
Using lookup, from_json, and filters, specific data can be extracted from a JSON file, transforming it into a usable format.
Write a playbook to validate host connectivity in the combined inventory.
Correct Answer:
- name: Validate connectivity hosts: all
tasks:
- name: Ping hosts ping:
Explanation:
Testing host connectivity ensures that all hosts in the combined inventory are reachable and configured correctly.
Create a playbook to run only tasks tagged as install.
Correct Answer:
# playbook.yml
- name: Tagged tasks example hosts: all
tasks:
- name: Install nginx yum:
name: nginx
state: present tags: install
Execution:
ansible-playbook -i inventory.yml playbook.yml --tags "install"
Explanation:
Tags allow selective execution of tasks in a playbook, making debugging and incremental updates more efficient.
0
0
0
10