최신 EX374 무료덤프 - RedHat Red Hat Certified Specialist in Developing Automation with Ansible Automation Platform

Convert a list of dictionaries into a single dictionary.
정답:
- name: Flatten dictionaries hosts: localhost
vars: dict_list:
- key1: value1
- key2: value2
tasks:
- name: Merge dictionaries debug:
var: "{{ dict_list | combine }}"
Explanation:
The combine filter merges a list of dictionaries into one, simplifying complex data processing tasks.
Create an inventory to manage multiple environments like staging and production.
정답:
# inventory.yml
staging:
hosts:
web1:
ansible_host: 192.168.1.11 production:
hosts:
web1:
ansible_host: 192.168.1.20
Explanation:
Environment-specific inventories simplify deployments and maintenance across diverse infrastructure setups.
Create a credential in Automation Controller for accessing an EE registry.
정답:
1. Go to Credentials.
2. Add a credential:
o Type: Container Registry
o Registry URL: registry.example.com
o Username and password.
Explanation:
Container registry credentials ensure Automation Controller can pull EEs securely.
Validate if a string matches a specific regular expression.
정답:
- name: Validate string hosts: localhost vars:
text: "ansible_123" tasks:
- name: Check format fail:
msg: "String format invalid"
when: not text is match('^ansible_[0-9]+$')
Explanation:
The match filter evaluates whether a string adheres to a regex pattern, enforcing data consistency.
Create a custom variable in group_vars to manage a unique property for web_servers.
정답:
echo "nginx_version: 1.18" > group_vars/web_servers.yml
Explanation:
Group variables customize configurations for all hosts in a group, centralizing shared settings like software versions.
Create a survey for a job template in Automation Controller.
정답:
1. Edit a job template and enable Survey.
2. Add questions to collect runtime variables.
Explanation:
Surveys allow runtime customization of playbook executions based on user inputs.
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.
Create SSH machine credentials to access inventory hosts.
정답:
ansible-vault create ssh_creds.yml
Add credentials:
ansible_user: "admin"
ansible_ssh_private_key_file: "~/.ssh/id_rsa"
Explanation:
Machine credentials stored in a Vault file ensure secure and consistent access to inventory hosts.
Split db1 variables into multiple files: db1_connection.yml and db1_settings.yml. Include connection details and custom database settings.
정답:
echo "ansible_user: dbadmin" > host_vars/db1_connection.yml
echo "db_name: my_database" > host_vars/db1_settings.yml
Explanation:
Splitting variables into logical files enhances modularity and improves clarity for managing complex configurations.
Create a test directory for automated testing of your collection.
정답:
mkdir -p my_namespace/my_collection/tests
echo "---
# Test cases" > my_namespace/my_collection/tests/test.yml
Explanation:
Adding a test directory ensures the collection can be validated through automated test cases.
Create an inventory that uses multiple groups and defines variables for each.
정답:
# inventory.yml
all:
children:
web_servers: hosts: web1:
db_servers: hosts: db1:
vars:
ansible_user: deploy
Explanation:
Grouping hosts and defining variables globally ensures consistent configuration across multiple groups.
Test a custom inventory plugin.
정답:
ansible-inventory -i plugins/inventory/my_plugin.py --list
Explanation:
Testing custom plugins ensures they generate valid inventories compatible with Ansible playbooks.
Create a project in Automation Controller to pull content from a private Git repository using an SSH key.
정답:
1. Navigate to Credentials and add: o Type: Source Control
o Username: Leave blank
o SSH Private Key: Upload your private key.
2. Create a project:
o Source Control Type: Git
o URL: [email protected]:private/repo.git
o Credential: Select the SSH credential.
3. Sync the project.
Explanation:
Using an SSH key allows secure access to private repositories for pulling automation content.
Integrate an EE with a specific project in Automation Controller.
정답:
1. Go to Projects in Automation Controller.
2. Edit the project and assign the custom EE (registry.example.com/my_execution_env:1.0).
3. Save and test the integration with a Job Template.
Explanation:
Associating projects with specific EEs ensures tasks run in a controlled environment tailored to project requirements.
Write a playbook to execute tasks on a host only if the variable http_port is defined.
정답:
- name: Check http_port hosts: all
tasks:
- name: Validate http_port debug:
msg: "http_port is defined" when: http_port is defined
Explanation:
Checking variable existence with when avoids failures due to undefined variables, ensuring smoother playbook runs.
Use a source control credential in a project in Automation Controller.
정답:
1. Create a new project in Automation Controller.
2. Set the source type to Git.
3. Use the previously created source control credential.
4. Sync the project.
Explanation:
Integrating source control credentials with projects automates fetching playbooks and keeps configurations updated.

우리와 연락하기

문의할 점이 있으시면 메일을 보내오세요. 12시간이내에 답장드리도록 하고 있습니다.

근무시간: ( UTC+9 ) 9:00-24:00
월요일~토요일

서포트: 바로 연락하기