What is YAML and why is it preferred over plain text for playbooks?
YAML is a human-readable data-serialization language with a standardized format. It's preferred because it enforces structure (lists, dictionaries, types) which prevents inconsistent formatting and parsing errors that occur with free-form text files.
How does an Ansible playbook file start and what does it contain?
An Ansible playbook is a YAML file that begins with three hyphens (---). It contains one or more plays; each play specifies target hosts, the remote user, and a sequence of tasks that call Ansible modules.
What are tasks and modules in a playbook example?
Tasks are individual actions defined inside a play; they use Ansible modules to perform work. For example, the 'apt' module installs Apache and the 'copy' module places an HTML file on the server.
How do you run a playbook against a specific inventory file?
Use the command ansible-playbook -i <inventory_file> <playbook.yaml>, where -i points to your inventory listing the target hosts.
Why is gather_facts important at the start of a play?
gather_facts runs automatically to validate connectivity and collect system variables from the target host, which can be used in subsequent tasks and to ensure the host is reachable.
What network change is required to view the deployed site on EC2?
You must configure the EC2 instance's security group to allow inbound HTTP traffic on port 80 so the deployed application can be accessed from a browser.