Ansible Automation Research & Evidence-Based Practice 4 โ Questions and Answers
Question 1: What does Ansible's 'batteries included' philosophy mean in the context of evidence-based automation design?
- Ansible installs its own Python runtime
- Ansible ships with thousands of built-in modules covering common use cases without extra plugins (Correct answer)
- Ansible requires no configuration files
- Ansible manages its own SSH daemon
Correct answer: Ansible ships with thousands of built-in modules covering common use cases without extra plugins
Ansible's built-in module library covers most common infrastructure tasks so practitioners can rely on tested, maintained code rather than custom scripts.
Question 2: According to Ansible research and community practice, what is the recommended maximum number of tasks in a single task file before splitting into includes?
- 10
- 25
- There is no hard limit, but readability is the guide (Correct answer)
- 100
Correct answer: There is no hard limit, but readability is the guide
Ansible has no enforced task limit per file; the best-practice guide recommends splitting for readability and maintainability when files become unwieldy.
Question 3: Which Ansible feature allows practitioners to validate that collected facts match expected evidence before proceeding with tasks?
- Tags
- Assertions with the `assert` module (Correct answer)
- The `debug` module
- Block error handling
Correct answer: Assertions with the `assert` module
The `assert` module evaluates conditions against gathered facts and fails the play with a descriptive message if expectations are not met.
Question 4: What is the best-practice recommendation for storing Ansible playbooks and roles to enable team collaboration and change tracking?
- A shared NFS directory
- A version control system such as Git (Correct answer)
- A dedicated FTP server
- The Ansible control node's home directory
Correct answer: A version control system such as Git
Version control (Git) provides change history, branching, peer review, and rollbackโall essential for team-based infrastructure automation.
Question 5: Which Ansible construct is the evidence-based way to handle task failures gracefully and run cleanup tasks regardless of failure?
- rescue and always within a block (Correct answer)
- ignore_errors: yes on every task
- The failed_when directive only
- Using handlers for cleanup
Correct answer: rescue and always within a block
A `block` with `rescue` handles failure recovery and `always` runs cleanup tasks whether or not the block succeeded.
Question 6: What is the recommended way to document the purpose and usage of a custom Ansible role for other practitioners?
- Add comments inside tasks/main.yml
- Populate the README.md file in the role's root directory (Correct answer)
- Create a separate wiki page
- Add metadata to meta/main.yml only
Correct answer: Populate the README.md file in the role's root directory
The README.md in the role root is the standard documentation location recognized by Ansible Galaxy and other tooling.
Question 7: According to Ansible best practices, when should the `serial` keyword be used in a play?
- When tasks must run alphabetically
- When rolling updates require limiting the number of hosts updated simultaneously (Correct answer)
- When debugging a single host
- When variables must be evaluated sequentially
Correct answer: When rolling updates require limiting the number of hosts updated simultaneously
`serial` controls the batch size for rolling updates, ensuring only a subset of hosts are updated at once to maintain availability.
What does Ansible's 'batteries included' philosophy mean in the context of evidence-based automation design?