EX374 無料問題集「RedHat Red Hat Certified Specialist in Developing Automation with Ansible Automation Platform」
Create an inventory in Automation Controller using a dynamic inventory script.
正解:
1. Go to Inventories and add: o Name: Dynamic Inventory
o Source: Custom Script
o Script: Upload the inventory script (e.g., idm_inventory.py).
2. Sync the inventory.
Explanation:
Dynamic inventory scripts allow fetching host information from external systems like databases or cloud platforms.
o Source: Custom Script
o Script: Upload the inventory script (e.g., idm_inventory.py).
2. Sync the inventory.
Explanation:
Dynamic inventory scripts allow fetching host information from external systems like databases or cloud platforms.
Use ansible_facts to display the OS distribution of web1.
正解:
- name: Display OS distribution hosts: web1
tasks:
- debug:
var: ansible_distribution
Explanation:
Ansible facts provide detailed system information, enabling tailored configurations and playbook logic.
tasks:
- debug:
var: ansible_distribution
Explanation:
Ansible facts provide detailed system information, enabling tailored configurations and playbook logic.
Execute a task on a remote host (db1) and use its output in a task on the current host.
正解:
- name: Use delegated output hosts: web1
tasks:
- name: Get uptime from db1
command: uptime
delegate_to: db1
register: db1_uptime
- name: Display db1 uptime on web1 debug:
msg: "Uptime of db1: {{ db1_uptime.stdout }}"
Explanation:
Storing the output of a delegated task in a variable allows its use in subsequent tasks, bridging operations across hosts.
tasks:
- name: Get uptime from db1
command: uptime
delegate_to: db1
register: db1_uptime
- name: Display db1 uptime on web1 debug:
msg: "Uptime of db1: {{ db1_uptime.stdout }}"
Explanation:
Storing the output of a delegated task in a variable allows its use in subsequent tasks, bridging operations across hosts.
Gather facts for web1 but delegate the task to the control node.
正解:
- name: Gather facts on control node hosts: web1
tasks:
- name: Get system facts setup:
delegate_to: localhost
Explanation:
Delegating the setup module task to the control node ensures that facts for web1 are gathered from the control node's perspective.
tasks:
- name: Get system facts setup:
delegate_to: localhost
Explanation:
Delegating the setup module task to the control node ensures that facts for web1 are gathered from the control node's perspective.
Package the collection into a .tar.gz file for distribution.
正解:
ansible-galaxy collection build my_namespace/my_collection
Explanation:
The build command packages the collection, creating a compressed file ready for sharing or publishing.
Explanation:
The build command packages the collection, creating a compressed file ready for sharing or publishing.
Use a dynamic inventory to execute a playbook on a subset of hosts.
正解:
ansible-playbook -i dynamic_inventory.py site.yml --limit web1,db1
Explanation:
Limiting playbook execution to specific hosts in a dynamic inventory provides finer control over deployments.
Explanation:
Limiting playbook execution to specific hosts in a dynamic inventory provides finer control over deployments.
Control whether delegated facts are stored for the target host or the delegating host.
正解:
- name: Delegate and control facts hosts: web1
tasks:
- name: Gather facts for db1 setup:
delegate_to: db1
delegate_facts: false
Explanation:
Setting delegate_facts: false stores gathered facts in the context of the delegating host rather than the target.
tasks:
- name: Gather facts for db1 setup:
delegate_to: db1
delegate_facts: false
Explanation:
Setting delegate_facts: false stores gathered facts in the context of the delegating host rather than the target.
Set up notifications for job completions in Automation Controller.
正解:
1. Navigate to Notifications.
2. Add a new notification:
o Type: Email, Slack, or Webhook.
o Configure details.
3. Link it to a job template.
Explanation:
Notifications provide immediate feedback on job status, improving monitoring and responsiveness.
2. Add a new notification:
o Type: Email, Slack, or Webhook.
o Configure details.
3. Link it to a job template.
Explanation:
Notifications provide immediate feedback on job status, improving monitoring and responsiveness.
Validate the EE used in a job template.
正解:
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.
Install a collection from Ansible Galaxy using the requirements.yml file.
正解:
# 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.
Pull an EE from Automation Hub and use it in Automation Controller.
正解:
1. Add an EE in Automation Controller: o Name: Hub EE
o Image: hub.example.com/ee-image:1.0.
2. Assign it to a job template and run a playbook.
Explanation:
Pulling EEs from Automation Hub centralizes runtime management and ensures compatibility.
o Image: hub.example.com/ee-image:1.0.
2. Assign it to a job template and run a playbook.
Explanation:
Pulling EEs from Automation Hub centralizes runtime management and ensures compatibility.
Use an EE image to test an Ansible module.
正解:
podman run --rm -v $(pwd):/workspace -w /workspace my_execution_env:1.0 ansible -m ping -i localhost,
Explanation:
Testing an Ansible module in the EE ensures compatibility and proper functionality in the runtime environment.
Explanation:
Testing an Ansible module in the EE ensures compatibility and proper functionality in the runtime environment.
Pause execution between tasks to simulate manual intervention.
正解:
- name: Pause example hosts: all
tasks:
- name: Pause for 10 seconds pause:
seconds: 10
Explanation:
The pause module allows for intentional delays between tasks, simulating manual checks or staggered operations.
tasks:
- name: Pause for 10 seconds pause:
seconds: 10
Explanation:
The pause module allows for intentional delays between tasks, simulating manual checks or staggered operations.