EX374試験無料問題集「RedHat Red Hat Certified Specialist in Developing Automation with Ansible Automation Platform 認定」
Run a playbook with custom variables passed at runtime in Automation Controller.
正解:
1. Open a job template.
2. Under Extra Variables, add: variable_name: value
3. Launch the job.
Explanation:
Passing custom variables at runtime provides flexibility to adjust playbook behavior without modifying the playbook itself.
2. Under Extra Variables, add: variable_name: value
3. Launch the job.
Explanation:
Passing custom variables at runtime provides flexibility to adjust playbook behavior without modifying the playbook itself.
Create a custom directory for inventory files and use it during a playbook execution.
正解:
mkdir -p custom_inventory
echo "[web_servers]" > custom_inventory/inventory.ini
echo "web1 ansible_host=192.168.1.10" >> custom_inventory/inventory.ini ansible-playbook -i custom_inventory playbook.yml
Explanation:
Custom inventory directories organize host definitions for easier management, especially in large-scale deployments.
echo "[web_servers]" > custom_inventory/inventory.ini
echo "web1 ansible_host=192.168.1.10" >> custom_inventory/inventory.ini ansible-playbook -i custom_inventory playbook.yml
Explanation:
Custom inventory directories organize host definitions for easier management, especially in large-scale deployments.
Set up a playbook to display ansible_user for web1 using the inventory from inventory.yml.
正解:
# playbook.yml
- name: Display ansible_user hosts: web1
tasks:
- debug:
var: ansible_user
Execution:
ansible-playbook -i inventory.yml playbook.yml
Explanation:
The debug module helps display variable values, verifying the correct assignment of ansible_user from the inventory.
- name: Display ansible_user hosts: web1
tasks:
- debug:
var: ansible_user
Execution:
ansible-playbook -i inventory.yml playbook.yml
Explanation:
The debug module helps display variable values, verifying the correct assignment of ansible_user from the inventory.
Create a Vault file to store sensitive credentials for inventory hosts.
正解:
ansible-vault create sensitive_creds.yml
Add:
ansible_user: "admin"
ansible_password: "secure_password"
Explanation:
Storing sensitive data in an encrypted Vault file ensures it remains secure and inaccessible without proper authorization.
Add:
ansible_user: "admin"
ansible_password: "secure_password"
Explanation:
Storing sensitive data in an encrypted Vault file ensures it remains secure and inaccessible without proper authorization.
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.
Verify the directory structure of an existing collection.
正解:
tree ~/.ansible/collections/ansible_collections/my_namespace/my_collection
Explanation:
The tree command provides a visual representation of the collection structure, ensuring proper organization.
Explanation:
The tree command provides a visual representation of the collection structure, ensuring proper organization.
Sync dynamic inventory with Automation Controller.
正解:
1. Go to Inventories in Automation Controller.
2. Add a new inventory and set the source as Custom Script.
3. Upload the dynamic inventory script.
Explanation:
Syncing dynamic inventories with Automation Controller ensures up-to-date host management for jobs.
2. Add a new inventory and set the source as Custom Script.
3. Upload the dynamic inventory script.
Explanation:
Syncing dynamic inventories with Automation Controller ensures up-to-date host management for jobs.
Filter a list of dictionaries to include only those with a specific key-value pair.
正解:
- name: Filter dictionaries hosts: localhost
vars:
items:
- name: nginx
status: running
- name: mysql status: stopped
tasks:
- name: Get running services debug:
var: "{{ items | selectattr('status', 'equalto', 'running') | list }}"
Explanation:
The selectattr filter extracts dictionaries based on specific conditions, enabling precise data selection.
vars:
items:
- name: nginx
status: running
- name: mysql status: stopped
tasks:
- name: Get running services debug:
var: "{{ items | selectattr('status', 'equalto', 'running') | list }}"
Explanation:
The selectattr filter extracts dictionaries based on specific conditions, enabling precise data selection.
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.
Configure Automation Controller to use custom inventory scripts.
正解:
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.
Create a static inventory with groups web and db, each containing two hosts.
正解:
# 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.
Validate if a given string ends with a specific suffix.
正解:
- name: Validate string suffix hosts: localhost
vars:
filename: "document.txt" tasks:
- name: Check suffix fail:
msg: "File does not end with .txt" when: not filename.endswith(".txt")
Explanation:
The endswith method ensures filenames conform to expected extensions or formats.
vars:
filename: "document.txt" tasks:
- name: Check suffix fail:
msg: "File does not end with .txt" when: not filename.endswith(".txt")
Explanation:
The endswith method ensures filenames conform to expected extensions or formats.
Override the default user for all hosts in the web_servers group.
正解:
echo "ansible_user: webadmin" > group_vars/web_servers.yml
Explanation:
Defining group-level variables overrides individual host settings, ensuring uniformity across similar hosts.
Explanation:
Defining group-level variables overrides individual host settings, ensuring uniformity across similar hosts.