Skip to main content
In this lesson you’ll use Red Hat Ansible Lightspeed (within the VS Code Ansible extension) to generate a complete, production-ready Ansible playbook from a natural-language prompt such as “install and start httpd”. Lightspeed will propose tasks, modules, parameters, and proper indentation. You will create a workspace, generate and refine a playbook named site.yml, add a templated page and a handler, ask Lightspeed to explain the result, and validate and run the playbook.
A slide titled "Lightspeed Playbook Test" showing a DevOps team on the left and a flow on the right from the Red Hat Ansible Lightspeed logo to the VS Code logo, with the caption "Prompts to playbooks."
Scenario: your team has connected Red Hat Ansible Lightspeed to VS Code and wants to evaluate how effectively Lightspeed converts plain-English prompts into playbooks that follow best practices for RHEL-based targets. The goal: a working playbook that installs and starts Apache (httpd), deploys a simple templated index page, and restarts the service when the template changes.
A dark-themed slide titled "Demo" showing a six-step checklist split into two columns. Steps include creating a new workspace, creating a playbook file called site.yml using Lightspeed, reviewing generated code, adding a templating task and handler, explaining the playbook, and validating.
Quick checklist (what you’ll do)
  • Create a workspace and inventory
  • Create a playbook file site.yml using Lightspeed
  • Review and refine generated tasks and naming
  • Add a templated index.html and a handler to restart Apache
  • Ask Lightspeed to explain the playbook
  • Validate and run the playbook
Step-by-step: create the workspace and basic configuration on your control node. Create the workspace directory:
Create a minimal inventory file that defines the webservers group:
Create a minimal ansible.cfg that points to the inventory and configures privilege escalation:
Open the lightspeed working directory in VS Code and use the Ansible extension / Lightspeed UI controls to generate a playbook.
A dark-themed Visual Studio Code welcome screen showing Ansible Lightspeed controls in a left sidebar, walkthroughs and start options in the center, and a "Build with agent mode" pane on the right. The UI also displays buttons for generating playbooks and roles and a feedback section.
Prompt provided to Lightspeed (example):
Lightspeed analyzes that prompt and proposes a complete playbook. After reviewing and refining the generated content for naming consistency and best practices (for example: capitalized task names, consistent module namespaces), this demo uses the following site.yml:
Why these choices
  • ansible.builtin.yum: appropriate for RHEL-based systems (CentOS, RHEL, Alma, Rocky).
  • become: True: ensures privileged operations (package install, service control) run with elevated privileges.
  • Template + handler pattern: updates the site content idempotently and restarts Apache only when the template changes.
Create the template referenced by the playbook at templates/index.html.j2:
Ask Lightspeed to “explain” the playbook — it will list prerequisites, describe each task and handler, and summarize expected results in plain language. For example: the playbook installs httpd on hosts in group webservers, ensures the service is running and enabled, deploys a templated index.html, and restarts Apache only when the template changes.
Lightspeed generates code, explains it, and suggests improvements — but always review generated playbooks for naming conventions, idempotence, and environment-specific constraints (for example SELinux context, firewall rules, or custom package sources).
Save the playbook as site.yml and run it from the control node:
Example (abridged) output when running the playbook:
Artifacts you created Notes on limitations and follow-ups
  • Lightspeed excels at generation and explanation from natural language prompts, accelerating playbook creation.
  • For larger, already-complex projects you may still need source-focused refactoring tools or manual review to enforce organization (roles, variables, testing pipelines).
  • Consider adding SELinux and firewall tasks if your environment requires them, and include molecule tests for role-level validation.
References Congratulations — you now have a simple, production-ready playbook generated and refined with Lightspeed, complete with a templated index.html and a handler to restart Apache when the template changes.

Watch Video