RedHat Red Hat Certified Specialist in Developing Automation with Ansible Automation Platform (EX374) Free Practice Test
Question 1
Generate a list of numbers from 1 to 10 using filters.
Correct Answer:
- name: Generate number range hosts: localhost
tasks:
- name: Create range debug:
var: "{{ range(1, 11) | list }}"
Explanation:
The range filter generates sequential numbers, useful for looping or numerical data generation.
tasks:
- name: Create range debug:
var: "{{ range(1, 11) | list }}"
Explanation:
The range filter generates sequential numbers, useful for looping or numerical data generation.
Question 2
Run a playbook in Automation Controller using an execution environment (EE).
Correct Answer:
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.
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.
Question 3
Combine multiple lists into one list using filters.
Correct Answer:
- name: Combine lists hosts: localhost vars:
list1: [1, 2, 3]
list2: [4, 5, 6] tasks:
- name: Merge lists debug:
var: "{{ list1 + list2 }}"
Explanation:
Combining lists into a single structure is straightforward with Ansible filters, enabling unified data manipulation.
list1: [1, 2, 3]
list2: [4, 5, 6] tasks:
- name: Merge lists debug:
var: "{{ list1 + list2 }}"
Explanation:
Combining lists into a single structure is straightforward with Ansible filters, enabling unified data manipulation.
Question 4
Run a playbook in check mode to simulate the changes it would make without applying them.
Correct Answer:
ansible-playbook -i inventory.yml playbook.yml --check
Explanation:
Check mode (--check) validates playbook logic without applying changes, providing a preview of the potential effects of execution.
Explanation:
Check mode (--check) validates playbook logic without applying changes, providing a preview of the potential effects of execution.
Question 5
You need to revert the last commit on the main branch without removing the changes locally. Revert the commit.
Correct Answer:
git revert HEAD
Explanation:
Reverting creates a new commit that undoes the changes made by the specified commit, maintaining the repository's integrity.
Explanation:
Reverting creates a new commit that undoes the changes made by the specified commit, maintaining the repository's integrity.
Question 6
Clone a private repository using the source control credential.
Correct Answer:
ansible-playbook git_clone.yml --vault-password-file vault_pass.txt git_clone.yml:
- name: Clone repository hosts: localhost tasks:
- git:
repo: "https://github.com/private/repo.git"
dest: "~/repo"
version: "main"
key_file: "~/.ssh/id_rsa"
Explanation:
Using git module with secure credentials fetches repositories for automated deployments or configurations.
- name: Clone repository hosts: localhost tasks:
- git:
repo: "https://github.com/private/repo.git"
dest: "~/repo"
version: "main"
key_file: "~/.ssh/id_rsa"
Explanation:
Using git module with secure credentials fetches repositories for automated deployments or configurations.
Question 7
View the status of your local repository to determine untracked files and staged changes.
Correct Answer:
git status
Explanation:
git status shows the current state of the working directory and staging area, helping track changes.
Explanation:
git status shows the current state of the working directory and staging area, helping track changes.
Question 8
Assign multiple credentials to a job template.
Correct Answer:
1. Open the job template.
2. Under Credentials, add:
o Machine credentials for host access.
o Source control credentials for pulling playbooks.
3. Save the template and run.
Explanation:
Assigning multiple credentials allows playbooks to access multiple resources, such as repositories and managed hosts.
2. Under Credentials, add:
o Machine credentials for host access.
o Source control credentials for pulling playbooks.
3. Save the template and run.
Explanation:
Assigning multiple credentials allows playbooks to access multiple resources, such as repositories and managed hosts.
Question 9
Sort a list of numbers in descending order using a filter.
Correct Answer:
- name: Sort numbers hosts: localhost vars:
numbers: [5, 3, 8, 1] tasks:
- name: Display sorted numbers debug:
var: "{{ numbers | sort(reverse=True) }}"
Explanation:
The sort filter orders list elements, and the reverse parameter inverts the order, enabling advanced sorting operations.
numbers: [5, 3, 8, 1] tasks:
- name: Display sorted numbers debug:
var: "{{ numbers | sort(reverse=True) }}"
Explanation:
The sort filter orders list elements, and the reverse parameter inverts the order, enabling advanced sorting operations.
Question 10
Configure Automation Controller to pull an EE from a private container registry.
Correct Answer:
1. Add Container Registry credentials: o Registry URL: registry.example.com o Username and password.
2. Add the EE:
o Name: Private EE
o Image: registry.example.com/my_execution_env:latest
3. Use this EE in a job template.
Explanation:
Pulling EEs from private registries ensures secure and controlled access to customized runtime environments.
2. Add the EE:
o Name: Private EE
o Image: registry.example.com/my_execution_env:latest
3. Use this EE in a job template.
Explanation:
Pulling EEs from private registries ensures secure and controlled access to customized runtime environments.