Ansible Automation Technology & Digital Applications 3 — Questions and Answers
Question 1: What is the function of the 'serial' keyword in an Ansible playbook?
- Controls how many hosts are updated at a time in a rolling deployment (Correct answer)
- Runs tasks sequentially instead of in parallel
- Sets the order of variable precedence
- Limits the number of forks
Correct answer: Controls how many hosts are updated at a time in a rolling deployment
The serial keyword enables rolling updates by specifying how many hosts (as a number or percentage) are processed per batch before moving to the next.
Question 2: Which Ansible feature allows you to test playbook syntax without executing any tasks on remote hosts?
- --syntax-check flag (Correct answer)
- --dry-run flag
- --validate flag
- --no-exec flag
Correct answer: --syntax-check flag
The --syntax-check flag parses the playbook and checks for YAML and Ansible syntax errors without connecting to or modifying any hosts.
Question 3: What does Ansible Molecule primarily provide for role developers?
- A testing framework for Ansible roles and collections (Correct answer)
- A GUI for managing playbooks
- A module for molecule/chemical data
- A linting tool for YAML files
Correct answer: A testing framework for Ansible roles and collections
Molecule provides a framework for testing Ansible roles by spinning up infrastructure (Docker, VMs), running playbooks, and verifying the resulting state.
Question 4: In Ansible, what is a 'fact cache' used for?
- Storing gathered facts to disk so they can be reused across playbook runs (Correct answer)
- Caching downloaded modules locally
- Storing task results in memory during a play
- Persisting handler notifications between runs
Correct answer: Storing gathered facts to disk so they can be reused across playbook runs
Fact caching stores gathered host facts to a backend (JSON files, Redis, etc.) so subsequent playbook runs can use cached facts without re-gathering them.
Question 5: Which network automation feature allows Ansible to build device configurations from templates?
- Jinja2 templates with network modules (Correct answer)
- NETCONF only
- SSH config files
- Ansible Galaxy templates
Correct answer: Jinja2 templates with network modules
Ansible uses Jinja2 templates combined with network-specific modules (like cisco.ios.ios_config) to render and push device configurations.
Question 6: What is the difference between 'include_tasks' and 'import_tasks' in Ansible?
- include_tasks is dynamic (runtime), import_tasks is static (parse time) (Correct answer)
- import_tasks is dynamic, include_tasks is static
- They are identical with different syntax
- include_tasks only works in roles
Correct answer: include_tasks is dynamic (runtime), import_tasks is static (parse time)
import_tasks is processed at playbook parse time (static), while include_tasks is evaluated at runtime (dynamic), allowing conditional inclusion based on variables.
Question 7: Which Ansible connection plugin enables managing network devices that don't support Python?
- network_cli (Correct answer)
- ssh_raw
- paramiko
- netconf
Correct answer: network_cli
The network_cli connection plugin allows Ansible to manage network devices via CLI over SSH without requiring Python on the remote device.
What is the function of the 'serial' keyword in an Ansible playbook?