Ansible – Role Vs. Playbook Top Differences

Here’re the differences between role and Playbook. With Ansible DevOps Tool you can automates deployment tasks.

Deployment, in the traditional approach is tedious but it’s easy with deployment Orchestrators. The can take care of password management, monitoring, and deployment.

Ansible: Role Vs. Playbook

Roles

  1. Role and Playbook both are the same in principle. It has individual files. Instead of having a single file that contains everything that you need – one for variables, one for tasks, and another for handlers.
  2. You can’t run a role on its own, you need to include it inside a playbook along with the information about which hosts to run on.
  3. When installing a role, you can either install it globally on your machine or locally to a project. As with any dependency, you want it to be local to your project in case multiple projects need different versions of the same dependency.
  4. Roles play prime function in Ansible. They keep playbooks clean and readable.
  5. You can store the roles that you created in https://galaxy.ansible.com/ , which is a public directory.

Playbook

  1. Playbooks play superior role.
  2. A play book is a big file, that contain all the infrastructure needed, to run
  3. Playbooks and roles are similar. Different at the same time. A playbook is a standalone file that Ansible can run that contains all of the information required to set a machine’s state to what you expect.
  4. A playbook can contain variables, tasks, handlers, roles, and even other playbooks, all in the same file. You don’t need any other files to accomplish your task.
  5. So, the playbook is a Master file, which is executable. The role file, you cannot execute on its own.

How to Create a Role

  • When creating a role, make sure it is usable out of the box. If your role installs a specific piece of software, make it install and configure a basic installation without user intervention.
  • Two types of roles present – Opinionated and un-opinionated.
    • In the public galaxy, you will find Un-opinionated roles -means general use.
    • The Opinionated roles – pertains to a certain app or clients. Checkout here steps to create a Role.

Deployment Orchestrator: Ansible

  1. Role & Playbook
  2. How to create a Role in Ansible

Top Deployment Orchestrators

Top five deployment orchestrators.

PuppetBroad community support
 Some coding skills recommended
 Extensible using Ruby
 Requires agents installed on all clients
ChefIntegrated with Git
 Some coding skills recommended
 Extensible using Ruby
 High learning curve
 Broad community support
 Requires chef-client installed on all clients
AnsibleSysadmin friendly
 Python-based
 No code needed, no host-based agents
 Simple, fast connections work via SSH
 Run via text-based files (called playbooks)
 Minimal learning curve
SaltWorks through agents (called minions)
 Highly scalable
 Sysadmin friendly
List of Top Deployment Orchestrators.

Keep Reading

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.