Ansible Playbook Definition and Format
Short answer
A Ansible playbooks are YAML files defining ordered automation tasks applied to managed hosts.
Question
Key Takeaways
Ansible playbooks are YAML files that define ordered automation tasks for managed hosts. Option A is correct because YAML provides the human-readable structure required for Ansible's declarative automation model.
Expert Analysis
Ansible playbooks are YAML files containing ordered tasks applied to managed hosts.
The core of network automation with Ansible relies on its declarative and idempotent nature, which is fundamentally expressed through Playbooks. A Playbook is not a procedural script written in a general-purpose programming language like Python or Bash; rather, it is a configuration document that defines the desired state of the target infrastructure. In the context of exam objective 2.4 (Construct a device-level network automation solution with Ansible to manage configurations) and 3.4 (Construct a controller-based network automation solution with Ansible to manage configurations), understanding this distinction is critical for correct implementation and troubleshooting.
Option A, "YAML file defining automation tasks," is the only correct description. Ansible uses YAML (YAML Ain't Markup Language) as its syntax for Playbooks because it is human-readable, easy to write, and effectively structured for describing hierarchical data structures such as hosts, variables, and task lists. When an Ansible Playbook is executed, the Ansible engine parses this YAML file and translates the defined tasks into actions performed on the managed nodes. These tasks are typically implemented via modules—reusable pieces of code that handle specific operations like configuring interfaces, managing users, or deploying software. The Playbook orchestrates these modules, ensuring they run in a specific order and handle dependencies between them.
Option B, "Python script," is incorrect because while Ansible itself is written in Python, the user-facing definition of automation logic in a Playbook is not Python code. Although Ansible supports custom modules written in Python, Ruby, or other languages, the structure that ties these modules together—the Playbook—is strictly YAML. Confusing the underlying engine language with the configuration format is a common pitfall. If one were to write a Python script to configure devices, they would likely be using libraries like Netmiko or NAPALM, which is a different paradigm from Ansible's module-driven, YAML-defined approach.
Option C, "Shell script," is incorrect for similar reasons. Shell scripts are procedural and imperative, focusing on the sequence of commands to execute. While Ansible can execute shell commands via the shell or command modules, the Playbook itself does not consist of raw shell syntax. Using shell scripts directly for automation often leads to issues with idempotency and error handling, whereas Ansible Playbooks enforce checks to ensure that tasks only make changes when necessary, maintaining system stability.
Option D, "JSON config," is incorrect. JSON (JavaScript Object Notation) is widely used in REST APIs and NETCONF/RESTCONF exchanges, but it is not the native format for Ansible Playbooks. While Ansible can interact with JSON data (for example, when parsing API responses or using the json_query filter), the structural definition of a Playbook must adhere to YAML syntax rules. YAML is a superset of JSON in terms of data representation, but they are distinct formats. Using JSON for Playbooks would require strict adherence to JSON syntax (like mandatory double quotes and commas), which Ansible does not support for Playbook definitions; it expects standard YAML formatting.
Therefore, recognizing that Ansible Playbooks are YAML-based documents that define ordered tasks is essential for mastering Ansible-based network automation. This aligns with the broader goal of constructing scalable, maintainable, and readable automation solutions that can be version-controlled and easily understood by team members.
Official Reference
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_intro.html
This link opens the official vendor documentation in a new tab.
Exam Strategy
When answering questions about Ansible, always distinguish between the tool's internal language (Python) and its configuration format (YAML). Remember that Playbooks are declarative documents describing desired states, not procedural scripts. For multi-select questions involving Ansible components, associate Playbooks with YAML, Modules with Python/reusability, and Roles with directory structures.
Related Analysis
Practice All 300-435 Questions
Access 150 questions with complete answers and detailed explanations.
View Full 300-435 Practice Test →