dgt_devops06 – Ansible – Playbooks, Roles and Modules

Module Title: dgt_devops06 – Ansible: Playbooks, Roles, and Modules


Overview:
The module “dgt_devops06 – Ansible: Playbooks, Roles, and Modules” covers configuration management with Ansible. This module explores the core concepts of configuration management and idempotency, and then turns them into practice: you will automate infrastructure tasks by instructing the machine in natural language and verifying everything it produces.

What You’ll Learn:

  1. Introduction to Configuration Management:
  2. Understand the importance of configuration management in maintaining system consistency.
  3. Explore key principles such as version control, automation and repeatability.

  4. Idempotency in Ansible:

  5. Grasp the concept of idempotency and why it is crucial for reliable automation.
  6. Learn how Ansible ensures that repeated executions yield the same system state without unintended changes.

  7. Deep Dive into Playbooks:

  8. Understand how playbooks are structured, organized and executed, so you can describe the desired state to the machine and judge the playbook it writes.
  9. Explore task execution order, conditional statements and error handling within playbooks.

  10. Roles:

  11. Learn about roles as a means of organizing tasks, handlers, files, templates and variables.
  12. Understand role dependencies and how roles are shared and reused across different projects.

  13. Exploring Ansible Modules:

  14. Get familiar with the built-in modules and when each one is the right choice for an automation task.
  15. Understand when a custom module is justified, and how to specify one so precisely that the machine can write it and you can review it.

  16. Natural-Language Practice:

  17. Apply the concepts through labs in which you describe the target configuration in plain language and the machine writes and runs the Ansible code.
  18. Review the playbooks, roles and modules it produces: check that they are idempotent, well structured and safe, run them again to prove that nothing changes, and correct the machine whenever it drifts.

For example, you might ask the machine: “Install nginx on the webservers group, publish our index.html with the right owner and permissions, and restart nginx only if something changed.” The playbook below is the kind of result it returns. Your job is to read it and confirm that it uses the right modules, that the handler is triggered only on change, and that the file permissions are what you asked for.

Example Snippet of an Ansible Playbook:

“`yaml

  • name: Configure Web Server
    hosts: webservers
    become: yes

tasks:
– name: Install nginx
apt:
name: nginx
state: present
notify:
– restart nginx

- name: Copy index.html to web server root
  copy:
    src: /path/to/local/index.html
    dest: /var/www/html/index.html
    owner: www-data
    group: www-data
    mode: 0644

handlers:
– name: restart nginx
service:
name: nginx
state: restarted
“`

Who Should Attend?
This module is intended for system administrators, DevOps engineers and IT professionals who work on infrastructure automation with Ansible. It can also serve as a structured introduction to configuration management concepts.

Module Outcomes:
By the end of this module, you will be able to design effective configuration management solutions with Ansible and have them implemented through precise natural-language instructions. You will know how to verify that the playbooks the machine produces are idempotent and reusable, spot what is wrong when they are not, and guide it to consistent, efficient automation across your infrastructure.

The students can push their exercises to the Academy DevOps & SRE Git project. For this module, create a folder with your username as its name in the following subfolder: https://github.com/Garanti-Del-Talento/gdt_academy