最新的RedHat Red Hat Certified Specialist in Developing Automation with Ansible Automation Platform - EX374免費考試真題
問題1
Transform a list of numbers by doubling each value.
正確答案:
- name: Double numbers in a list hosts: localhost
vars:
numbers: [1, 2, 3, 4] tasks:
- name: Transform list debug:
var: "{{ numbers | map('multiply', 2) | list }}"
Explanation:
Using the map filter with multiply applies transformations to each element in a list.
vars:
numbers: [1, 2, 3, 4] tasks:
- name: Transform list debug:
var: "{{ numbers | map('multiply', 2) | list }}"
Explanation:
Using the map filter with multiply applies transformations to each element in a list.
問題2
Retrieve data from a YAML file using lookup.
正確答案:
# 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.
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.
問題3
Set up a database query as a dynamic inventory source.
正確答案:
# db_inventory.py import sqlite3, json
connection = sqlite3.connect("inventory.db")
cursor = connection.cursor()
cursor.execute("SELECT hostname, ip FROM hosts")
inventory = {"all": {"hosts": {}}}
for row in cursor.fetchall():
inventory["all"]["hosts"][row[0]] = {"ansible_host": row[1]}
print(json.dumps(inventory))
Explanation:
Dynamic inventory from a database ensures inventories are generated based on up-to-date information stored in the database.
connection = sqlite3.connect("inventory.db")
cursor = connection.cursor()
cursor.execute("SELECT hostname, ip FROM hosts")
inventory = {"all": {"hosts": {}}}
for row in cursor.fetchall():
inventory["all"]["hosts"][row[0]] = {"ansible_host": row[1]}
print(json.dumps(inventory))
Explanation:
Dynamic inventory from a database ensures inventories are generated based on up-to-date information stored in the database.
問題4
Create a project in Automation Controller to pull content from a private Git repository using an SSH key.
正確答案:
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.
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.
問題5
Use a dynamic inventory to filter hosts by a specific tag.
正確答案:
ansible-inventory -i aws_ec2.yml --host tag_web
Explanation:
Filtering hosts by tag ensures that only the relevant resources are targeted for playbook execution.
Explanation:
Filtering hosts by tag ensures that only the relevant resources are targeted for playbook execution.
問題6
Check the metadata of an installed collection.
正確答案:
cat ~/.ansible/collections/ansible_collections/my_namespace/my_collection/galaxy.yml
Explanation:
Viewing the metadata file confirms details such as version, author, and dependencies of an installed collection.
Explanation:
Viewing the metadata file confirms details such as version, author, and dependencies of an installed collection.
問題7
Set up a schedule to update EEs in Automation Controller.
正確答案:
1. Go to Schedules in Automation Controller.
2. Create a schedule for the Execution Environment Sync.
3. Set the frequency to match organizational update policies.
Explanation:
Scheduling updates ensures EEs are always up-to-date with the latest dependencies and fixes.
2. Create a schedule for the Execution Environment Sync.
3. Set the frequency to match organizational update policies.
Explanation:
Scheduling updates ensures EEs are always up-to-date with the latest dependencies and fixes.
問題8
Run a playbook in Automation Controller using an execution environment (EE).
正確答案:
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.
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.
問題9
Run a playbook on web1 with a specific ansible_connection type.
正確答案:
# host_vars/web1.yml ansible_connection: ssh
Explanation:
The ansible_connection variable defines the protocol for communicating with hosts, useful for automation adjustments.
Explanation:
The ansible_connection variable defines the protocol for communicating with hosts, useful for automation adjustments.

