dgt_devops06 – Ansible – Ad Hoc Command Lab

Module Title: dgt_devops06 – Ansible – Ad Hoc Command Lab

Module Description:

The “Ansible – Ad Hoc Command Lab” module covers configuration management with a focus on Ansible’s ad hoc commands. The lab is intended for DevOps professionals who automate IT operations and infrastructure management.

Here the practice is entirely in natural language. You tell the machine what you need (“check free disk space on every web server”, “make sure httpd is running on the staging group”), it chooses the module and runs the ad hoc command, and you read that command and its output: is the inventory pattern right, is the module idempotent, did it actually change something it shouldn’t have?

Key Learning Objectives:

  1. Understanding Configuration Management Concepts:
  2. Gain a foundational understanding of what configuration management entails, including the benefits of maintaining consistent configurations across environments.
  3. Explore the principles of idempotency in Ansible and how it ensures that repeated operations yield the same result without unintended side effects.

  4. Ad Hoc Commands with Ansible:

  5. Learn how ad hoc commands run quick tasks on remote hosts without full playbooks, so you can ask the machine for exactly the right one and recognize a wrong one.
  6. Practice real-world scenarios in which you direct rapid troubleshooting and task automation in natural language.

  7. Natural-Language Labs:

  8. Interactive labs in which you instruct the machine to run ad hoc commands across various servers and verify the results host by host.
  9. Ask for tasks such as file management, service control and system checks, and judge whether the Ansible module the machine picked is the right one.

  10. Introduction to Playbooks:

  11. While the focus is on ad hoc commands, you’ll also learn how simple Ansible playbooks are structured, so you can ask the machine to turn a series of ad hoc tasks into one and review it.
  12. Analyze a sample playbook snippet to understand how it automates configuration tasks in a repeatable and scalable manner.

Sample Ansible Playbook Snippet:

“`yaml

  • name: Ensure Apache is installed and running
    hosts: webservers
    become: yes
    tasks:

    • name: Install Apache web server
      ansible.builtin.yum:
      name: httpd
      state: present

    • name: Start Apache service
      ansible.builtin.service:
      name: httpd
      state: started
      enabled: yes
      “`

Module Benefits:

  • Develop the skills to manage and automate IT infrastructure with Ansible by instructing the machine precisely and checking its work.
  • Enhance your understanding of configuration management principles, particularly idempotency, to ensure reliable and predictable system states.
  • Gain practical experience that can be directly applied to real-world DevOps challenges.

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