Understanding roles in Ansible

As easy as Ansible is to get started with, and as readable as a playbook is when it is short, it does get more complex, as do the requirements. In addition, there are certain functions that may well be needed repeatedly in different scenarios. For example, you might need to deploy a MariaDB database server as a common task in your environment. A module called apt is used for managing packages on Ubuntu servers, and so, if we wanted to install the mariadb-server package on our test system, the playbook to perform this task could look like this:

---- name: Install MariaDB Server  hosts: localhost  become: true  tasks:    - name: Install mariadb-server package      apt:        name: mariadb-server        update_cache: yes

Note that this ...

Get Hands-On Enterprise Automation on Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.