
更新された2025年10月テストエンジンに練習EX374テスト問題
EX374リアル試験問題テストエンジン問題集トレーニングには300問あります
質問 # 162
Filter a list of strings to include only those that match a regex pattern.
正解:
解説:
- 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.
質問 # 163
Write a requirements.yml file to specify the collections and Python packages required in the EE.
正解:
解説:
# requirements.yml
collections:
- name: ansible.posix version: 1.3.0
- name: community.general version: 3.0.0
python:
- name: boto3 version: ">=1.20.0"
Explanation:
The requirements.yml file lists Ansible collections and Python packages, ensuring the execution environment contains all necessary dependencies.
質問 # 164
Use delegation to upload a file to an S3 bucket from the control node.
正解:
解説:
- name: Upload to S3 hosts: web1 tasks:
- name: Upload file
command: aws s3 cp /tmp/example.txt s3://mybucket/
delegate_to: localhost
Explanation:
Delegating cloud operations to the control node centralizes cloud-related tasks, improving efficiency.
質問 # 165
Execute a task on multiple delegated hosts using a loop.
正解:
解説:
- name: Delegate to multiple hosts hosts: web1
tasks:
- name: Ping multiple hosts ping:
delegate_to: "{{ item }}" with_items:
- db1
- db2
Explanation:
The loop iterates over a list of hosts and delegates the ping task to each, verifying connectivity for multiple targets.
質問 # 166
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.
質問 # 167
Create a directory structure where host variables for web1 are stored in host_vars/web1.yml and group variables for web_servers in group_vars/
web_servers.yml.
正解:
解説:
mkdir -p host_vars group_vars
echo "ansible_host: 192.168.1.10" > host_vars/web1.yml
echo "http_port: 80" > group_vars/web_servers.yml
Explanation:
Using host_vars and group_vars directories organizes variables by host and group, improving scalability and readability of variable assignments.
質問 # 168
Fetch a file from a managed node to the control node using delegation.
正解:
解説:
- 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.
質問 # 169
Create a playbook to override the default inventory SSH port by using a special variable at runtime.
正解:
解説:
# playbook.yml
- name: Test connection with overridden SSH port hosts: web1
tasks:
- ping:
Execution:
ansible-playbook -i inventory.yml playbook.yml -e "ansible_port=2022"
Explanation:
Passing ansible_port as an extra variable ensures runtime overrides without altering the inventory.
質問 # 170
Automate inventory updates with a cron job.
正解:
解説:
crontab -e
Add:
0 * * * * ansible-inventory -i dynamic_inventory.py --list > inventory_cache.json
Explanation:
Automating inventory updates ensures the inventory stays current without manual intervention.
質問 # 171
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.
質問 # 172
Create a playbook to find all IP addresses in a text file.
正解:
解説:
- name: Extract IP addresses hosts: localhost
tasks:
- name: Read file and extract IPs set_fact:
ip_list: "{{ lookup('file', '/tmp/ips.txt') | regex_findall('\b(?:\d{1,3}\.){3}\d{1,3}\b') }}"
- debug:
var: ip_list
Explanation:
Using regex_findall, this playbook extracts all IP addresses from a file, enabling network data parsing.
質問 # 173
Extract the domain name from an email address using the regex_search filter.
正解:
解説:
- name: Extract domain from email hosts: localhost
vars:
email: "[email protected]" tasks:
- name: Get domain debug:
var: "{{ email | regex_search('@(.*)') }}"
Explanation:
The regex_search filter allows complex string manipulation by extracting specific patterns like domains from email addresses.
質問 # 174
Validate if a given variable contains a valid MAC address using a filter.
正解:
解説:
- name: Validate MAC address hosts: localhost
vars:
mac_address: "00:1A:2B:3C:4D:5E" tasks:
- name: Check MAC validity fail:
msg: "Invalid MAC address" when: not mac_address | macaddr
Explanation:
The macaddr filter checks the validity of a MAC address, ensuring proper handling of network-related data.
質問 # 175
Create a custom plugin for generating inventory.
正解:
解説:
# plugins/inventory/my_plugin.py
from ansible.plugins.inventory import BaseInventoryPlugin
class InventoryModule(BaseInventoryPlugin):
NAME = 'my_plugin'
def parse(self, inventory, loader, path, cache):
inventory.add_host('host1', group='all')
Explanation:
Custom inventory plugins allow highly tailored inventory generation for unique use cases.
質問 # 176
Split a list into chunks of a specified size.
正解:
解説:
- name: Chunk list hosts: localhost vars:
items: [1, 2, 3, 4, 5, 6] tasks:
- name: Create chunks
debug:
var: "{{ items | batch(2) }}"
Explanation:
The batch filter splits a list into smaller groups of specified size, useful for parallel processing.
質問 # 177
......
EX374実際の問題解答PDFには100%カバー率リアル試験問題:https://jp.fast2test.com/EX374-premium-file.html
EX374試験問題解答:https://drive.google.com/open?id=1WxOINzdD_HlQu_kaqQahAXCy5974ApWP