Free EX374 Questions for RedHat Red Hat Certified Specialist in Developing Automation with Ansible Automation Platform EX374 Exam as PDF & Practice Test Engine
Publish the collection to Ansible Galaxy.
Correct Answer:
ansible-galaxy collection publish my_namespace-my_collection-1.0.0.tar.gz --api-key <your_galaxy_api_key>
Explanation:
The publish command uploads the collection to Ansible Galaxy, making it accessible to the community or other users.
Explanation:
The publish command uploads the collection to Ansible Galaxy, making it accessible to the community or other users.
Validate the EE used in a job template.
Correct Answer:
1. Go to Jobs and select the template.
2. Check the Execution Environment field in the job details.
Explanation:
Validating ensures the correct EE is associated, providing the necessary dependencies for playbook execution.
2. Check the Execution Environment field in the job details.
Explanation:
Validating ensures the correct EE is associated, providing the necessary dependencies for playbook execution.
Run a command on the control node but store the result in the context of a managed host.
Correct Answer:
- name: Store control node result hosts: web1
tasks:
- name: Get disk usage on control node
command: df -h
delegate_to: localhost
register: disk_usage
- name: Show disk usage debug:
var: disk_usage
Explanation:
This task demonstrates delegating commands to the control node while retaining results within the managed host's context.
tasks:
- name: Get disk usage on control node
command: df -h
delegate_to: localhost
register: disk_usage
- name: Show disk usage debug:
var: disk_usage
Explanation:
This task demonstrates delegating commands to the control node while retaining results within the managed host's context.
Create a static inventory with groups web and db, each containing two hosts.
Correct Answer:
# 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.
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.
Split db1 variables into multiple files: db1_connection.yml and db1_settings.yml. Include connection details and custom database settings.
Correct Answer:
echo "ansible_user: dbadmin" > host_vars/db1_connection.yml
echo "db_name: my_database" > host_vars/db1_settings.yml
Explanation:
Splitting variables into logical files enhances modularity and improves clarity for managing complex configurations.
echo "db_name: my_database" > host_vars/db1_settings.yml
Explanation:
Splitting variables into logical files enhances modularity and improves clarity for managing complex configurations.
Add dependencies to your collection's galaxy.yml file, such as requiring the community.general collection.
Correct Answer:
# galaxy.yml
dependencies: community.general: ">=3.0.0"
Explanation:
The dependencies section in galaxy.yml ensures that required collections are automatically installed when your collection is used.
dependencies: community.general: ">=3.0.0"
Explanation:
The dependencies section in galaxy.yml ensures that required collections are automatically installed when your collection is used.
Write a playbook to use the lookup plugin to retrieve a secret from a file.
Correct Answer:
- 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.
- 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.
Convert all keys in a dictionary to uppercase.
Correct Answer:
- name: Uppercase dictionary keys hosts: localhost
vars:
my_dict: key1: value1 key2: value2
tasks:
- name: Transform keys debug:
var: "{{ my_dict | dict2items | map('update', {'key': item.key | upper}) | items2dict }}"
Explanation:
This transformation leverages filters to apply case modifications to dictionary keys.
vars:
my_dict: key1: value1 key2: value2
tasks:
- name: Transform keys debug:
var: "{{ my_dict | dict2items | map('update', {'key': item.key | upper}) | items2dict }}"
Explanation:
This transformation leverages filters to apply case modifications to dictionary keys.
Configure Automation Controller to use custom inventory scripts.
Correct Answer:
1. Go to Inventories in Automation Controller.
2. Add a new inventory and set the source to Custom Script.
3. Upload the custom script.
Explanation:
Custom inventory scripts provide flexibility to fetch and manage hosts in complex environments.
2. Add a new inventory and set the source to Custom Script.
3. Upload the custom script.
Explanation:
Custom inventory scripts provide flexibility to fetch and manage hosts in complex environments.
Filter a list of strings to include only those that match a regex pattern.
Correct Answer:
- name: Filter strings hosts: localhost vars:
items: ["web01", "db01", "web02"] tasks:
- name: Get web servers debug:
var: "{{ items | select('match', '^web') | list }}"
Explanation:
The select filter combined with match extracts list elements matching a specific regex pattern, allowing advanced filtering.
items: ["web01", "db01", "web02"] tasks:
- name: Get web servers debug:
var: "{{ items | select('match', '^web') | list }}"
Explanation:
The select filter combined with match extracts list elements matching a specific regex pattern, allowing advanced filtering.
Assign multiple credentials to a job template.
Correct Answer:
1. Open the job template.
2. Under Credentials, add:
o Machine credentials for host access.
o Source control credentials for pulling playbooks.
3. Save the template and run.
Explanation:
Assigning multiple credentials allows playbooks to access multiple resources, such as repositories and managed hosts.
2. Under Credentials, add:
o Machine credentials for host access.
o Source control credentials for pulling playbooks.
3. Save the template and run.
Explanation:
Assigning multiple credentials allows playbooks to access multiple resources, such as repositories and managed hosts.
Write a playbook to display all variables assigned to a host.
Correct Answer:
- 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.
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.
Inspect the logs of an EE build process.
Correct Answer:
podman logs $(podman ps -aq --filter ancestor=my_execution_env:1.0)
Explanation:
Inspecting logs helps troubleshoot issues that occur during the build process, ensuring a functional EE.
Explanation:
Inspecting logs helps troubleshoot issues that occur during the build process, ensuring a functional EE.
Install a collection from Ansible Galaxy using the requirements.yml file.
Correct Answer:
# 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.
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.
0
0
0
10
