Lab Guide: Configuring Ansible Lightspeed in VS Code

A guide to enabling and activating Ansible Lightspeed within the Ansible Visual Studio Code extension.


Introduction and Lab Setup

Important Note About This Lab

IBM watsonx Code Assistant models are continuously updated and improved. As a result, some specific task generation challenges in this lab may not work exactly as described due to model updates. This is expected behavior.

The primary goal of this lab is to help you understand the key features of Ansible Lightspeed, including:

  • Playbook Generation - Generating entire playbooks from natural language prompts

  • Task Generation - Generating individual tasks or multiple tasks at once

  • Training Matches - Understanding the transparency of AI suggestions

  • Best Practices - Learning how Lightspeed incorporates Ansible best practices

If a specific prompt doesn’t generate suggestions as expected:

  • Try playbook generation instead of task generation (use the "Generate a playbook" button to create the entire playbook from a prompt)

  • Experiment with different prompt variations to see what gives you the best suggestions

  • Simplify complex multi-task prompts into separate single-task prompts

  • The learning objectives remain the same: understanding how to work with AI-assisted Ansible development

In this lab, you will configure Ansible Lightspeed in Visual Studio Code. You will sign up for the Ansible Lightspeed trial service using your own Red Hat account.

The examples used in this lab are available in the Ansible Lightspeed Demo repository.

Your lab environment provides access to multiple services via the tabs at the top:

  • VS Code - Visual Studio Code development environment with Ansible extension pre-installed

  • Ansible Automation Platform - Automation controller for running automation jobs

  • Cockpit - Cockpit web console for system monitoring (after setup in Module 2)

  • PGAdmin - PostgreSQL administration interface (after setup in Module 3)

  • AWS/Azure - Cloud account credentials for AWS and Azure resources (used in later challenges)

  • gitea - Internal Git repository hosting the lab playbooks

Lab Credentials

Different services in this lab use different credentials:

  • Automation Controller: admin / ansible123!

  • Gitea (Git Repository): gitea / gitea

  • VS Code: Access via browser tab (no login required)


Task 1: Sign Up for Ansible Lightspeed Trial

Before using Ansible Lightspeed, you need to sign up for a trial subscription. This requires creating a Red Hat account and subscribing to both Ansible Automation Platform and Ansible Lightspeed trials.

If you have previously completed this lab:

  • Within 60-day trial window: If you completed this lab within the last 60 days, your trial is still active. Use the same Red Hat account and skip to Task 2.

  • After 60-day trial window: If your trial has expired, you will need to create a new Red Hat account using a different email address to access new AAP and Lightspeed trials. Each account can only access the trial once.

  • If you have an AAP subscription: If your email is already attached to a paid AAP subscription, you can still access the Ansible Lightspeed trial with that account.

  • No available email addresses: Unfortunately, there is no workaround if you do not have access to a new email address. Each Red Hat account can only activate the trial one time.

If you already have a Red Hat account with active Ansible Lightspeed trial access, you can skip to Task 2.

Step 1: Create a Red Hat Account

  1. Visit the Red Hat account creation page at access.redhat.com

  2. Complete the registration form with your information and verify your email address.

Step 2: Subscribe to Ansible Automation Platform Trial

  1. Visit the Ansible Automation Platform trial page at https://www.redhat.com/en/technologies/management/ansible/trial

  2. Log in with your newly created Red Hat account credentials.

  3. Complete the trial signup process for Ansible Automation Platform.

You must have an active Ansible Automation Platform trial subscription before you can access the Ansible Lightspeed trial.

Step 3: Enable Ansible Lightspeed Trial

You will enable the Ansible Lightspeed trial directly from VS Code as part of the connection process in Task 2.


Task 2: Enable and Connect Ansible Lightspeed in VS Code

Now you will enable Ansible Lightspeed in VS Code and connect it to the trial service.

Step 1: Open VS Code and Enable Lightspeed Settings

  1. Access VS Code:

    • VS Code opens automatically as the first tab when you start the lab

    • If you need to reopen it, click the VS Code tab at the top of your lab environment

    • Note: Clicking the VS Code tab may open it in a new browser tab

Work in a new browser tab: For the best experience with Ansible Lightspeed features, click the VS Code tab to open it in a new browser tab rather than using the inline embedded window.

  1. Navigate to the Ansible extension settings:

    • Click the Extensions icon on the left sidebar

    • Find the Ansible extension

    • Click the gear icon (⚙️)

    • Select Extension Settings

  2. Enable Lightspeed features:

    • Click the Workspace tab

    • Type lightspeed in the search bar to filter settings

    • Check both boxes:

      • Enable Ansible Lightspeed

      • Enable Ansible Lightspeed with Watson Code Assistant inline suggestions

Please ensure you configure these settings in the VS Code Workspace tab, not the User tab.

If VS Code prompts you to Reload Window to update the extensions, click the Reload Window button to apply the changes.

Step 2: Connect to Ansible Lightspeed Service

  1. Click the Ansible extension icon on the left sidebar in VS Code.

  2. Click the Connect button in the Ansible Lightspeed section.

  3. Follow the authentication prompts:

    • VS Code will show pop-ups guiding you through authentication

    • Click Allow when prompted to open the authentication page

    • Click Open to launch your browser

  4. Log in with your Red Hat account:

    • A browser window will open to the Red Hat login page

    • Enter your Red Hat account credentials (the account you created in Task 1)

    • Click Log In

  5. Authorize VS Code to access Ansible Lightspeed:

    • After logging in, you’ll see an authorization page

    • Click Authorize to grant VS Code access

  6. Complete the authentication redirect:

    • The browser will redirect back to VS Code

    • Click Open in the VS Code prompt to complete the connection

    • You should now see Logged in as <your-email> in the Ansible extension sidebar

  7. Start the Ansible Lightspeed trial:

    • In the Ansible extension sidebar (left side), look for the Start Trial button in the Ansible Lightspeed section

    • Click the Start Trial button

    • A browser window will open with the Ansible Lightspeed trial terms and conditions

    • Read and accept the terms and conditions

    • After accepting, the browser will confirm your trial is activated

  8. Refresh and verify the trial is enabled:

    • Return to VS Code

    • In the Ansible Lightspeed section of the Ansible extension sidebar, click the refresh icon (circular arrow)

    • You should now see that your Ansible Lightspeed trial is enabled and active

    • A confirmation notification may appear in the bottom right corner

The Ansible Lightspeed trial is NOT automatically activated after AAP trial signup. You must explicitly click Start Trial in VS Code and accept the terms and conditions for the trial to become active.

If you receive a timeout warning during authentication, simply click Connect in the Ansible extension again and repeat the authorization steps.


Task 3: Understanding Playbook Generation (Optional)

Now that you’ve set up Ansible Lightspeed, let’s explore the playbook generation feature. This is one of the most powerful features of Ansible Lightspeed, allowing you to create entire playbooks from natural language prompts.

Work in a new browser tab: Ansible Lightspeed may not work correctly in the inline VS Code window embedded in the lab interface. Always click the VS Code tab to open it in a new browser tab for the best experience with Lightspeed features.

Step 1: Access Playbook Generation

  1. Open the playbook generation interface:

    1. On the left side of VS Code, click the Ansible icon (looks like an "A")

    2. In the Ansible Lightspeed section, click the Generate a playbook button

      • Note: This button only appears after you have successfully logged in and activated your trial

Step 2: Enter Your Prompt

  1. Describe what you want to achieve:

    1. A new screen will open with a text box labeled "Describe what you want to achieve in natural language"

    2. Enter a description of what you want your playbook to do

    3. Click the Analyze button

Writing effective prompts:

  • You do NOT need to include phrases like "Generate a playbook" or "Create a playbook" - the AI knows it’s creating playbooks

  • Just describe what you want your playbook to do in plain language

  • Be specific about the tasks you want to accomplish

Example prompts:

  • for rhel hosts with sudo, install and configure Apache web server with SSL enabled

  • configure PostgreSQL database on CentOS hosts and create a backup user

You’ll also see example prompts listed in the interface that you can use for inspiration.

Step 3: Review and Edit the Outline

  1. Review the suggested playbook structure:

    1. After clicking Analyze, Ansible Lightspeed will show an outline of the playbook

    2. The outline shows the suggested steps for your playbook

    3. The outline is editable - you can modify the steps as needed to match your requirements

    4. Review the outline and make any adjustments if necessary

  2. Generate the playbook:

    1. Once you’re satisfied with the outline, click the Continue button

    2. Ansible Lightspeed will generate the complete playbook based on the outline

Step 4: Save the Playbook

  1. Save your generated playbook:

    1. The playbook will open as "Untitled" in the editor

    2. Press CTRL+S (Windows/Linux) or CMD+S (Mac) to save the file

    3. Give your playbook a descriptive name ending with .yml (for example: install_apache.yml, configure_database.yml)

    4. Choose a location to save it (the playbooks/ directory is recommended for organization)

You can experiment with playbook generation now, or proceed to the next module where you’ll use both task generation and playbook generation features in hands-on challenges.


Next Steps

Congratulations! You have successfully configured Ansible Lightspeed in VS Code. You are now ready to start generating Ansible content using AI-powered suggestions.

Do not skip this module! Without completing the Ansible Lightspeed setup, you will not be able to get AI suggestions in the subsequent challenges.

Press the button below to proceed to the next module where you will use Ansible Lightspeed to deploy Cockpit.


Additional Resources


Troubleshooting

Common Issues

Issue: "I’m logged in but don’t see the Start Trial button"

  • Solution: Make sure you have completed the AAP trial signup first. The Start Trial button only appears if you have an active AAP trial subscription. Try clicking the refresh icon in the Ansible Lightspeed section.

Issue: "I clicked Start Trial but my trial still shows as not enabled"

  • Solution: After accepting the terms and conditions in the browser, return to VS Code and click the refresh icon (circular arrow) in the Ansible Lightspeed section of the Ansible extension sidebar.

Issue: "I don’t see the option to enable Ansible Lightspeed trial"

  • Solution: Ensure you have completed the Ansible Automation Platform trial signup first. The Lightspeed trial requires an active AAP trial subscription.

Issue: "Connection times out during authentication"

  • Solution: Click Connect in the Ansible extension again and repeat the authorization steps. Make sure pop-ups are not blocked in your browser.

Issue: "I already have a Red Hat account but no AAP trial"

Issue: "My 60-day trial has expired and I don’t have another email address"

  • Solution: Unfortunately, there is no workaround. Each Red Hat account can only activate the trial one time. You would need a different email address to create a new account.

If you encounter other issues, please check the official documentation or contact Red Hat support.