Ansible Automation Research & Evidence-Based Practice 5 — Questions and Answers
Question 1: Which evidence-based practice does Ansible's collection structure enforce compared to standalone roles?
- Collections must be written in Python
- Collections bundle roles, modules, plugins, and documentation into a versioned, distributable unit (Correct answer)
- Collections replace inventory files
- Collections only work with Ansible Automation Platform
Correct answer: Collections bundle roles, modules, plugins, and documentation into a versioned, distributable unit
Collections package all related automation content together with versioning, enabling reproducible, shareable automation at scale.
Question 2: What is the best-practice way to ensure an Ansible execution environment is reproducible across different control nodes?
- Manually install dependencies on each control node
- Use an execution environment image built with ansible-builder (Correct answer)
- Copy the virtual environment to each node
- Pin Ansible version in a README
Correct answer: Use an execution environment image built with ansible-builder
`ansible-builder` creates container-based execution environments that bundle Ansible, collections, and Python dependencies into a portable image.
Question 3: According to Ansible's security research guidance, what is the risk of using `no_log: false` on tasks that handle secrets?
- The task will fail silently
- Sensitive values will appear in verbose output and log files (Correct answer)
- The vault password will be exposed to handlers
- Fact gathering will be disabled
Correct answer: Sensitive values will appear in verbose output and log files
Without `no_log: true`, sensitive module arguments are printed in Ansible's verbose output and stored in any configured log file.
Question 4: What does the Ansible community identify as the primary benefit of using `delegate_to` in a playbook?
- Running tasks as a different user
- Executing a task on a different host than the one currently being iterated (Correct answer)
- Assigning tasks to specific worker threads
- Delegating variable lookups to a remote host
Correct answer: Executing a task on a different host than the one currently being iterated
`delegate_to` redirects task execution to a specified host while still using the current host's variables, useful for registration or load-balancer operations.
Question 5: Which Ansible practice does the `molecule` framework support in evidence-based role development?
- Building container images from Dockerfiles
- Testing roles in isolated environments with multiple verifier options (Correct answer)
- Generating API documentation
- Encrypting role variables automatically
Correct answer: Testing roles in isolated environments with multiple verifier options
Molecule provides a testing harness for Ansible roles, spinning up instances, applying the role, and running verifiers like Testinfra or Ansible itself.
Question 6: What is the evidence-based advantage of using `loop` over the deprecated `with_items` in modern Ansible playbooks?
- `loop` is faster because it uses multithreading
- `loop` is the standardized keyword and supports more data structures via `lookup` plugins (Correct answer)
- `loop` automatically flattens nested lists
- `loop` skips failed iterations automatically
Correct answer: `loop` is the standardized keyword and supports more data structures via `lookup` plugins
`loop` is the modern, unified iteration keyword replacing `with_*` constructs, and it integrates cleanly with `lookup` and `query` plugins.
Question 7: According to Ansible's performance research, what is the primary purpose of enabling pipelining in ansible.cfg?
- It allows parallel fact gathering
- It reduces SSH connections per task by sending multiple operations over a single connection (Correct answer)
- It enables asynchronous task execution
- It compresses transferred files
Correct answer: It reduces SSH connections per task by sending multiple operations over a single connection
Pipelining eliminates the need to create a temporary file per task by piping module code over the existing SSH connection, significantly reducing overhead.
Which evidence-based practice does Ansible's collection structure enforce compared to standalone roles?