Version control of roles in Ansible

Role reuse is an important part of building an efficient, standardized system of playbooks for administrators and engineers to apply. We have given many examples throughout this bookfor example, in Chapter 10, Managing Users on Linux—we proposed a simple role that would add users to a Linux system. To save you referring back, the code is as follows:

---- name: Add required users to Linux servers  user:    name: "{{ item.name }}"    comment: "{{ item.comment }}"    shell: /bin/bash    groups: "{{ item.groups }}"    append: yes    state: present  loop:    - { name: 'johndoe', comment: 'John Doe', groups: 'sudo'}    - { name: 'janedoe', comment: 'Jane Doe', groups: 'docker'}

Given our discussion about role reuse, I'm sure that you ...

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.