최신 EX374 무료덤프 - RedHat Red Hat Certified Specialist in Developing Automation with Ansible Automation Platform
Configure db1 to use a specific shell for commands via a host variable.
정답:
echo "ansible_shell_type: bash" > host_vars/db1.yml
Explanation:
Defining ansible_shell_type ensures compatibility with the host's shell environment, avoiding errors during execution.
Explanation:
Defining ansible_shell_type ensures compatibility with the host's shell environment, avoiding errors during execution.
Undo changes made to config.txt before staging the file.
정답:
git checkout -- config.txt
Explanation:
git checkout -- <file> reverts changes in the working directory to the last committed state.
Explanation:
git checkout -- <file> reverts changes in the working directory to the last committed state.
Use a dynamic inventory to filter hosts by a specific tag.
정답:
ansible-inventory -i aws_ec2.yml --host tag_web
Explanation:
Filtering hosts by tag ensures that only the relevant resources are targeted for playbook execution.
Explanation:
Filtering hosts by tag ensures that only the relevant resources are targeted for playbook execution.
You are given access to a Git repository with the URL https://github.com/example/repo.git. Clone the repository to your local machine in the directory /home/user/projects.
정답:
cd /home/user/projects
git clone https://github.com/example/repo.git
Explanation:
Cloning a repository retrieves all files, branches, and history to your local system. The git clone command initiates this process by downloading the specified repository.
git clone https://github.com/example/repo.git
Explanation:
Cloning a repository retrieves all files, branches, and history to your local system. The git clone command initiates this process by downloading the specified repository.
Use a survey to capture runtime inputs for a job template.
정답:
1. Edit the job template and enable Survey.
2. Add survey questions:
o Name: Environment
o Type: Multiple Choice
o Options: Dev, Test, Prod
3. Save and launch the job.
Explanation:
Surveys provide a user-friendly way to collect runtime inputs, enabling customization of playbook execution.
2. Add survey questions:
o Name: Environment
o Type: Multiple Choice
o Options: Dev, Test, Prod
3. Save and launch the job.
Explanation:
Surveys provide a user-friendly way to collect runtime inputs, enabling customization of playbook execution.
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.
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.
- 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.
Automate the update process for EEs in Automation Controller.
정답:
1. Use the awx-manage command:
awx-manage update_execution_environments --url registry.example.com/my_execution_env --username user --password pass
2. Schedule this command as a cron job.
Explanation:
Automating EE updates ensures they remain current without manual intervention, reducing maintenance overhead.
awx-manage update_execution_environments --url registry.example.com/my_execution_env --username user --password pass
2. Schedule this command as a cron job.
Explanation:
Automating EE updates ensures they remain current without manual intervention, reducing maintenance overhead.
Run a task on a different host than the one defined in the inventory using delegate_to.
정답:
- name: Delegate task to another host hosts: web1
tasks:
- name: Run a command on db1
command: uptime
delegate_to: db1
Explanation:
The delegate_to keyword ensures the task is executed on db1, even if the play is targeting web1. This is useful for tasks requiring resources or operations on another host.
tasks:
- name: Run a command on db1
command: uptime
delegate_to: db1
Explanation:
The delegate_to keyword ensures the task is executed on db1, even if the play is targeting web1. This is useful for tasks requiring resources or operations on another host.
Write a playbook to display all registered variables from previous tasks.
정답:
- name: Display variables hosts: all
tasks:
- name: Run command
command: echo "Hello"
register: command_output
- debug:
var: command_output
Explanation:
The register directive stores task outputs in variables, making them accessible for subsequent tasks.
tasks:
- name: Run command
command: echo "Hello"
register: command_output
- debug:
var: command_output
Explanation:
The register directive stores task outputs in variables, making them accessible for subsequent tasks.
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.
Use the EE to execute a playbook that requires an external library not in the base image.
정답:
1. Update requirements.yml:
python:
- name: requests version: ">=2.25.0"
2. Rebuild the EE:
ansible-builder build --tag my_execution_env:1.1
3. Run the playbook:
podman run --rm -v $(pwd):/workspace -w /workspace my_execution_env:1.1 ansible-playbook site.yml
Explanation:
Adding external libraries ensures compatibility with modules requiring additional dependencies.
python:
- name: requests version: ">=2.25.0"
2. Rebuild the EE:
ansible-builder build --tag my_execution_env:1.1
3. Run the playbook:
podman run --rm -v $(pwd):/workspace -w /workspace my_execution_env:1.1 ansible-playbook site.yml
Explanation:
Adding external libraries ensures compatibility with modules requiring additional dependencies.
Check if all elements in a list are unique.
정답:
- name: Validate unique list hosts: localhost
vars:
items: [1, 2, 3, 4, 5] tasks:
- name: Ensure uniqueness
fail:
msg: "List contains duplicates"
when: items | length != items | unique | length
Explanation:
By comparing the length of the original and deduplicated list, this check ensures all elements are unique.
vars:
items: [1, 2, 3, 4, 5] tasks:
- name: Ensure uniqueness
fail:
msg: "List contains duplicates"
when: items | length != items | unique | length
Explanation:
By comparing the length of the original and deduplicated list, this check ensures all elements are unique.
You need to check the current configuration settings of your Git environment. Display them.
정답:
git config --list
Explanation:
Viewing configuration settings verifies the global and repository-specific settings for consistency.
Explanation:
Viewing configuration settings verifies the global and repository-specific settings for consistency.