Write a playbook to retry a failed task up to three times.
正解:
- name: Retry task hosts: all
tasks:
- name: Retryable task
command: echo "Retry example"
retries: 3
delay: 5
until: false
Explanation:
The retries directive attempts task execution multiple times, useful for transient issues.
質問 2:
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.
質問 3:
Copy a file to all hosts in a group from the control node using delegation.
正解:
- name: Copy file to all hosts hosts: localhost
tasks:
- name: Copy file copy:
src: /tmp/example.txt
dest: /tmp/example.txt delegate_to: "{{ item }}" with_items: "{{ groups['all'] }}"
Explanation:
Using delegate_to with a loop and groups['all'], the file is copied from the control node to all hosts in the inventory.
質問 4:
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.
質問 5:
Create a requirements.yml file to define multiple collections for installation.
正解:
# requirements.yml
collections:
- name: community.general version: 3.0.0
- name: ansible.posix version: 1.3.0
ansible-galaxy collection install -r requirements.yml
Explanation:
The requirements.yml file defines dependencies, allowing batch installation of multiple collections in a single command.
質問 6:
Create a custom configuration for the EE in Automation Controller.
正解:
1. Navigate to Execution Environments in the Automation Controller.
2. Add a new EE entry:
o Name: Custom EE
o Image: registry.example.com/my_execution_env:1.0
3. Associate the EE with a project or job template.
Explanation:
Customizing EEs in Automation Controller allows for task-specific runtime environments.
質問 7:
Configure a host db1 to use a specific username dbadmin and SSH key ~/.ssh/db_key. Ensure this is applied via host_vars.
正解:
mkdir -p host_vars
echo "ansible_user: dbadmin" > host_vars/db1.yml
echo "ansible_ssh_private_key_file: ~/.ssh/db_key" >> host_vars/db1.yml
Explanation:
Using host_vars allows granular control of variables, such as user credentials and SSH keys, for individual hosts.
1097 お客様のコメント





Ishikawa -
EX374問題集を利用した後、自信満々になりました。意外がなく、無事にEX374試験をパスしました。