Playbooks are a set of instructions written in YAML that define a set of tasks to be performed by Ansible. They are written to be reusable, maintainable, and easily understood. Playbooks can be used to configure systems, deploy applications, or manage complex workflows.
Roles are a way to group related tasks, files, and variables into one container. Roles are organized in a specific directory structure, and contain all the necessary components for a specific task, such as tasks, handlers, files, templates, and variables.
For example, a playbook might contain a role to install a web server. This role would include tasks to install the web server, configure it, and start it. It would also include files, templates, and variables needed to complete the task.