Chapter 5. Developing Ansible content


As an automation developer, you can use Red Hat Ansible Lightspeed to implement your organization’s automation strategy. Red Hat Ansible Lightspeed can help you create and use custom automation content. This chapter provides information about how to get set up as an automation developer on Red Hat Ansible Lightspeed, with details on how to:

  • Access the Ansible Lightspeed portal as an automation developer
  • Install and configure the VS Code
  • Create task recommendations
  • Create playbooks and view playbook explanations
  • Provide feedback on the Ansible Lightspeed service

You can access Red Hat Ansible Lightspeed through the Ansible Lightspeed portal. After you enter your Red Hat Single Sign-On (RH-SSO) account credentials, your account is authenticated and you are granted access. Your assigned user role is displayed on the login screen of the Ansible Lightspeed portal.

Expand
Table 5.1. User login scenarios
ScenarioResult

You are a RH-SSO user. This is the typical scenario for accessing Red Hat Ansible Lightspeed as an Ansible user.

You are routed to the Red Hat Ansible Lightspeed paid commercial offering.

You are a RH-SSO user, but your organization administrator has not configured Red Hat Ansible Lightspeed to connect with IBM watsonx Code Assistant.

You are routed to the Red Hat Ansible Lightspeed paid commercial offering with a message that your organization administrator has not configured a model for your organization.

Use the following procedure to log into the Ansible Lightspeed portal with your Red Hat account.

Procedure

  1. Go to the Ansible Lightspeed portal login page.
  2. Click Log in Log in with Red Hat.
  3. Enter your Red Hat account username and password.

    On successful authentication, the login screen is displayed along with your username and your assigned user role.

To log out of the Ansible Lightspeed Service, you must log out of both the Ansible Lightspeed VS Code extension and the Ansible Lightspeed portal.

Procedure

  • Log out of the Ansible Lightspeed VS Code extension:

    • Click the Person icon Person icon . You will see a list of accounts that VS Code is logged into.
    • Select Ansible Lightspeed Sign Out.
  • Log out of the Ansible Lightspeed portal:

Red Hat Ansible Lightspeed with IBM watsonx Code Assistant is integrated with the Ansible Visual Studio (VS) Code extension in VS Code. The Ansible VS Code extension, with Red Hat Ansible Lightspeed features enabled, automatically collects recommendations, usage telemetry, and Ansible YAML file state through automated events.

To access Red Hat Ansible Lightspeed, all Ansible users must install and configure the Ansible VS Code extension in their VS Code. The Ansible VS Code extension uses the Ansible-specific IBM watsonx Granite model configured in the Red Hat Ansible Lightspeed administrator portal as the default mode for all users in your organization.

5.2.1. Connectivity requirements

To generate code recommendations, the Ansible Lightspeed service in Visual Studio (VS) Code editor requires access to the following outbound domain:

The outbound connections are encrypted on TCP protocol port 443.

5.2.2. Installing the Ansible VS Code extension

Use the following procedure to install the Ansible Lightspeed extension in VS Code.

Prerequisites

  • VS Code version 1.70.1 or later.
Note

You can also install VScode derivatives, such as VScode Insider or VS Codium.

Procedure

  1. Open the VS Code application.
  2. From the navigation menu, click the Extensions icon.
  3. In the Search field, enter Ansible.
  4. Select Ansible to choose the Ansible language support extension published by Red Hat.
  5. Click Install.
  6. After installation is complete, verify your VSCode installation:

    1. Create a new YAML file using the .yml or .yaml file extension.
    2. From the Status toolbar, click the language indicator and select Ansible to associate the Ansible language type with the new YAML file.
    3. Start writing a test playbook. Contextual aids are displayed as you start creating your content.

5.2.3. Configuring the Ansible VS Code extension

Configure third-party LLM providers, such as IBM watsonx Code Assistant or Google Gemini, within the Ansible VS Code extension.

Prerequisites

  • You have installed the Ansible VS Code extension v25.12.3.
  • You have obtained a valid API key for your chosen third-party LLM provider.

Procedure

  1. Open the VS Code application.
  2. From the Activity bar, click the Extensions icon Extensions .
  3. From the Installed Extensions list, select Ansible.
  4. From the Ansible extension page, click the Settings icon and select Extension Settings.
  5. Select Ansible Lightspeed settings, and specify the following information:

    Expand
    UI fieldDescription

    Ansible Lightspeed: Enabled

    Select this checkbox to enable the Red Hat Ansible Lightspeed service.

    Ansible Lightspeed: Provider

    Select the active AI service for code generation.

    Choose the AI provider from the following options:

    • wca: (Default setting) Uses IBM watsonx Code Assistant as the AI provider.
    • google: Uses Google Gemini as the AI provider.

    Ansible Lightspeed: Model Name

    Specify the specific AI model version to use for code generation:

    • For IBM watsonx Code Assistant: (Required) The IBM watsonx Code Assistant model name or ID that you want to use for code generation.
    • For Google Gemini: (Optional) The system applies a recommended default model if left blank.

    Ansible Lightspeed: Api Key

    Specify the secret credential required to authenticate requests with third-party model providers.

    • For IBM watsonx Code Assistant: (Optional) This field is not used for the IBM WCA provider. IBM watsonx Code Assistant relies on a separate OAuth2 login flow via the Red Hat portal.
    • For Google Gemini: (Required) Paste your active Google Gemini API key into this field. This token authorizes the extension to send prompts to Google’s servers.

    Ansible Lightspeed: Api Endpoint

    Specify the destination URL for network requests sent by the Ansible VS Code extension.

    • For IBM watsonx Code Assistant: (Required) This field allows modification of the service URL for IBM watsonx Code Assistant connections. The default URL is https://c.ai.ansible.redhat.com.
    • For Google Gemini: (Not configurable) This setting is not configurable when using the Google provider. The extension automatically manages the correct endpoint URL for Google services internally.

    Ansible Lightspeed Suggestions: Enabled

    Toggle the automatic display of inline code completions within the Ansible VS Code editor. Inline suggestions are currently available for the IBM watsonx Code Assistant provider only.

    Ansible Lightspeed: Timeout

    Define the maximum duration the Ansible VS Code extension waits for a server response. The default timeout for API calls is 3000 milliseconds.

Result

Your settings are automatically saved in VS Code.

Note

If your organization recently subscribed to the Red Hat Ansible Automation Platform, it might take a few hours for Red Hat Ansible Lightspeed to detect the new subscription. In VS Code, use the Refresh button in the Ansible extension from the Activity bar to check again.

After installing and configuring the VS Code extension, you can log in to the Ansible Lightspeed service.

Red Hat Ansible Lightspeed provides different sign-in methods depending on whether you are using the cloud service or the on-premise deployment.

  • Ansible Lightspeed on-premise deployments

    Users are authenticated using your Red Hat Ansible Automation Platform login.

    To sign in, you can use the Connect button in the Ansible Lightspeed view, or the Sign in with Ansible Lightspeed to use Ansible option in the Accounts menu. Once prompted in the browser, select Log in with Ansible Automation Platform, and log in with the authorization mechanism that your automation controller is configured with.

  • Ansible Lightspeed cloud service

    Users are authenticated using Red Hat Single Sign-On (RH-SSO).

    To sign in from VS Code, you can use the Connect button in the Ansible Lightspeed view, or the Sign in with Ansible Lightspeed to use Ansible option in the Accounts menu. Follow the on-screen prompts to log in and access the Ansible Lightspeed service using your RH-SSO.

    Note

    If you are using a cloud development environment at a domain unknown by Ansible Lightspeed, such as on-premise Red Hat OpenShift Dev Spaces, your Accounts sign-in menu provides the option Sign-in with Red Hat to use Ansible.

    This option uses a device code flow to successfully complete the sign-in process and requires the Red Hat Authentication extension v0.2.0 or later. If you require this authentication flow but don’t see the Sign-in with Red Hat to use Ansible option, ensure you are using the Ansible VS Code extension v24.5.2 or later.

Procedure

  1. Open the VS Code application.
  2. Sign in using either the Connect button in the Ansible Lightspeed view or the Accounts menu.

    • Sign in using the Connect button:

      1. From the VS Code activity bar, click the Ansible icon.
      2. In the Ansible Lightspeed view, click Connect.
      3. Follow the on-screen prompts to sign in to Ansible Lightspeed.
    • Sign in using the Accounts menu:

      1. From the VS Code activity bar, click the Accounts menu.
      2. Sign in with Ansible Lightspeed to use Ansible or sign in with Red Hat to use Ansible, depending on the sign-in option you are presented with.

        Note
        • The sign-in options are displayed when the VS Code extension is in an active state. The extension is activated after you open the Ansible side panel or after you open an Ansible file in the VS Code editor. If you do not see this option, use the Connect button to link to the Ansible Lightspeed service.
        • If you are using a cloud development environment at a domain unknown by Ansible Lightspeed, such as on-premise Red Hat OpenShift Dev Spaces, your Accounts sign-in menu provides the option Sign-in with Red Hat to use Ansible. This option uses a device code flow to successfully complete the sign-in process and requires the Red Hat Authentication extension v0.2.0 or later. If you require this authentication flow but don’t see the Sign-in with Red Hat to use Ansible option, ensure you are using the Ansible VS Code extension v24.5.2 or later.
      3. Follow the on-screen prompts to sign in to Red Hat Ansible Lightspeed.

    On successful authentication, the login screen is displayed along with your username and your assigned user role.

To log out of the Ansible Lightspeed Service, you must log out of both the Ansible Lightspeed VS Code extension and the Ansible Lightspeed portal.

Procedure

  • Log out of the Ansible Lightspeed VS Code extension:

    • Click the Person icon Person icon . You will see a list of accounts that VS Code is logged into.
    • Select Ansible Lightspeed Sign Out.
  • Log out of the Ansible Lightspeed portal:

5.3. Creating task recommendations

Red Hat Ansible Lightspeed is integrated into Visual Studio (VS) Code through the Ansible VS Code extension. You can request code recommendations for your task intent by using Ansible VS Code extension.

You can perform the following tasks from the Ansible VS Code extension:

  • Create single task or multitask requests by using natural language prompts

    • Create a single task prompt

      Write a description of your task in the - name: key of a new task line in your Ansible file. For example, to automate a task of installing PostgreSQL server, you can enter the prompt - name: Install postgresql-server.

    • Create a multitask prompt

      Place your cursor on a new line in your Ansible YAML file at the correct indentation, and start your prompt with a Pound key (#).

      Write the descriptions of your tasks, separating each prompt by using Ampersand symbols (&). For example, to automate a multitask of installing PostgreSQL server and running the initial PostgreSQL setup command, you can enter the prompt # Install postgresql-server & run postgresql-setup command.

      The Ansible Lightspeed service reads the text, interacts with the IBM watsonx Code Assistant model, and generates Ansible task recommendations based on your natural language prompt.

      Note

      Currently, Red Hat Ansible Lightspeed supports user prompts in English language only. However, there could be instances where the training data that was used to train the IBM watsonx Code Assistant models included non-English language. In such scenarios, the model can generate code recommendations for prompts made in the same non-English language, but the generated code recommendations might or might not be accurate.

  • View the content source matching results

    For each generated code recommendation, Red Hat Ansible Lightspeed lists content source matches, including details such as potential source, content author, and relevant licenses. You can use this data to gain insight into potential training data sources used to generate the code recommendations.

  • Provide feedback on the Ansible Lightspeed service

    The Ansible Lightspeed service learns your organizational patterns and improves the code recommendation experience over time. You can provide feedback on whether the generated code recommendations were suitable for your task intent. This feedback enables Red Hat Ansible Lightspeed with IBM watsonx Code Assistant to improve on the quality of its suggestions.

5.3.2. Creating single task recommendations

You can request code recommendations for a single task by entering natural language prompts in Ansible VS Code extension. For example, to automate a task of installing a PostgreSQL server, you can enter the prompt - name: Install postgresql-server. The Ansible Lightspeed service reads the text, interacts with the IBM watsonx Code Assistant model, and generates the code recommendations.

Prerequisites

  • You meet one of the following requirements:

    • Your organization has a trial or paid subscription to both the Red Hat Ansible Automation Platform and IBM watsonx Code Assistant.
    • Your organization has a trial or paid subscription to the Red Hat Ansible Automation Platform, and you have a Red Hat Ansible Lightspeed trial account.
  • You have installed and configured the Ansible VS Code extension.

Procedure

  1. Log in to VS Code with your Red Hat account.
  2. Create a new YAML file or use an existing YAML file:

    • Create a YAML file:

      1. Select File New Text File.
      2. From the lower right of the screen, click Plain Text, and in the language mode, select Ansible.
      3. Save the file as a YAML file format extension (.yml or .yaml).
    • Use an existing YAML file:

      1. On the bottom right of the screen, click the existing language mode, and in the language mode settings, select Ansible.

        Note

        If you do not see the language mode section in your VS Code editor, from the Command Palette, select Configure Language Mode Ansible.

  3. Verify that you see an entry for Lightspeed on the status bar at the lower right of VS Code.

    If Ansible is already selected as the desired language but the Lightspeed entry is not displayed, re-select Ansible as the language mode. The following illustration shows Lightspeed and Ansible entries on the VS Code status bar.

    Figure 5.1. Ansible and Lightspeed set as selected language mode

    Settings show Ansible and Lightspeed as selected language mode
  4. Optional: If you see an error message about missing Ansible lint, you can install the missing module or disable it. Perform any one of the following tasks:

    • Install Ansible lint: For installation information, see the Installing section of the Ansible Lint documentation.
    • Disable Ansible lint:

      1. From the Activity bar, click the Extensions icon Extensions .
      2. From the Installed extensions list, select Ansible.
      3. From the Ansible extension page, click the Settings icon and select Extension Settings.
      4. Clear the Ansible › Validation › Lint: Enabled checkbox.
  5. Create a playbook or use an existing playbook.

    For more information, see the Getting started with playbooks guide.

  6. In the playbook, provide the following information to request code recommendations for a single task:

    1. Add a new Ansible task by starting a new line with - name: at the correct indentation.
    2. Add a detailed natural language prompt in the task description after - name: on the same line. For example, you can specify the following single task prompt: - name: Install postgresql-server
    3. Press Enter directly after the task description. Keep the cursor at the same location in your file, and wait for the code recommendation results to populate.

      The Ansible Lightspeed service is engaged, and it starts generating code recommendations for a single task.

      Important

      Ansible Lightspeed service takes around 5 seconds per task to populate the code recommendations. If you are using a multitask prompt, the Ansible Lightspeed service takes a bit longer (number of tasks times 5 seconds) to populate the results. Do not move your cursor or press any key while the code recommendation is being generated. If you change the cursor location or press any key, Ansible VS Code extension cancels the request and the Ansible Lightspeed service does not process your request.

      When the Ansible Lightspeed service is engaged, a Lightspeed processing status indicator is displayed in the lower right of the screen to denote that your code recommendation is being generated.

      Lightspeed icon

  7. View your code recommendations and ensure that the recommendations match your task intent.

    The following illustration shows the code recommendations generated by the Ansible Lightspeed service for the single task Install postgresql-server:

    Lightspeed single task in progress

  8. Accept or reject the code recommendations:

    • To accept a code recommendation, press Tab.
    • To reject a code recommendation, press Esc.

      Note

      If you reject a recommendation, you can modify the prompt and review the generated code recommendations once again to match your task intent.

  9. After you accept the code recommendation, click the ANSIBLE tab to see the content source matching results.

    For each generated code recommendation, Red Hat Ansible Lightspeed lists content source matches, including details such as potential source, content author, and relevant licenses. You can use this data to gain insight into potential training data sources used to generate the code recommendations.

  10. Click Save to save the code recommendation changes in your Ansible YAML file.

5.3.3. Creating multitask recommendations

You can request multitask code recommendations by entering a sequence of natural language task prompts in Ansible VS Code extension. In a YAML file, start your prompt with a pound symbol (#), and separate each prompt by using the ampersand symbol (&).

Example of a multitask prompt

# Install postgresql-server & run postgresql-setup command
Copy to Clipboard Toggle word wrap

For better readability, you can split your multitask inline prompts over multiple lines. To achieve this, end your current line with an ampersand symbol (&) and start the next line with the hash symbol (#).

Example of a multitask prompt split over multiple lines

# Create a keypair called lightspeed-keypair & create a vpc & create vpc_id var &
# create a security group that allows SSH & create subnet with 10.0.1.0/24 cidr &
# create an internet gateway & create a route table
Copy to Clipboard Toggle word wrap

The Ansible Lightspeed service reads the text, interacts with the IBM watsonx Code Assistant model, and generates the code recommendations.

Note

While entering a multitask prompt, the Ansible VS Code extension might display a warning if you have long lines in your prompt based on your ansible-lint settings. This warning is a minor readability error and does not impact the quality of your code recommendation output. To resolve the error, you can either ignore it or fix it by splitting your multitask inline prompt over multiple lines.

Prerequisites

  • You meet one of the following requirements:

    • Your organization has a trial or paid subscription to both the Red Hat Ansible Automation Platform and IBM watsonx Code Assistant.
    • Your organization has a trial or paid subscription to the Red Hat Ansible Automation Platform, and you have a Red Hat Ansible Lightspeed trial account.
  • You have installed and configured the Ansible VS Code extension.

Procedure

  1. Log in to VS Code with your Red Hat account.
  2. Create a new YAML file or use an existing YAML file.

    • Create a YAML file:

      1. Select File New Text File.
      2. From the lower right of the screen, click Plain Text, and in the language mode, select Ansible.
      3. Save the file as a YAML file format extension (.yml or .yaml).
    • Use an existing YAML file:

      1. On the bottom right of the screen, click the existing language mode, and in the language mode settings, select Ansible.

        Note

        If you do not see the language mode section in your VS Code editor, from the Command Palette, select Configure Language Mode Ansible.

  3. Verify that you see an entry for Lightspeed on the status bar at the lower right of VS Code.

    If Ansible is already selected as the desired language but the Lightspeed entry is not displayed, re-select Ansible as the language mode. The following illustration shows Lightspeed entry on the VS Code status bar.

    Figure 5.2. Ansible and Lightspeed set as selected language mode

    Settings show Lightspeed as selected language mode
  4. Optional: If you see an error message about missing Ansible lint, you can install the missing module or disable it. Perform any one of the following tasks:

    • Install Ansible lint: For installation information, see the Installing section of the Ansible Lint documentation.
    • Disable Ansible lint:

      1. From the Activity bar, click the Extensions icon Extensions .
      2. From the Installed extensions list, select Ansible.
      3. From the Ansible extension page, click the Settings icon and select Extension Settings.
      4. Clear the Ansible › Validation › Lint: Enabled checkbox.
  5. Create a playbook or use an existing playbook.

    For more information, see the Getting started with playbooks guide.

  6. In the playbook, provide the following information to request multitask code recommendations:

    1. Start a new YAML file comment by entering a pound symbol (#) at the correct indentation.
    2. Add a detailed natural language prompt in a sequence, separating each task by using the ampersand symbol (&).

      Example of a multitask prompt

      # Install postgresql-server & run postgresql-setup command
      Copy to Clipboard Toggle word wrap

      For better readability, split your multitask inline prompts over multiple lines. To achieve this, end your current line with an ampersand symbol (&) and start the next line with the hash symbol (#).

      Example of a multitask prompt split over multiple lines

      # Create a keypair called lightspeed-keypair & create a vpc & create vpc_id var &
      # create a security group that allows SSH & create subnet with 10.0.1.0/24 cidr &
      # create an internet gateway & create a route table
      Copy to Clipboard Toggle word wrap
    3. Press Enter directly after the task description. Keep the cursor at the same location in your file, and wait for the code recommendation results to populate.

      The Ansible Lightspeed service is engaged, and it starts generating code recommendations for multiple tasks.

      Important

      Ansible Lightspeed service takes around 5 seconds per task to populate the code recommendations. If you are using a multitask prompt, the Ansible Lightspeed service takes a bit longer (number of tasks times 5 seconds) to populate the results. Do not move your cursor or press any key while the code recommendation is being generated. If you change the cursor location or press any key, Ansible VS Code extension cancels the request and the Ansible Lightspeed service does not process your request.

      When the Ansible Lightspeed service is engaged, a Lightspeed processing status indicator is displayed in the lower right of the screen to denote that your code recommendation is being generated.

      Lightspeed icon

  7. Optional: If multitask code recommendations are not being generated, log out of VS Code and log in again using your Red Hat account.
  8. View your code recommendations and ensure that the recommendations match your task intent.

    The following illustration shows the code recommendations generated by the Ansible Lightspeed service for the multitask prompt Install postgresql-server & run postgresql-setup command: :

    Lightspeed single task in progress

  9. Accept or reject the code recommendations:

    • To accept a code recommendation, press Tab.
    • To reject a code recommendation, press Esc.

      Note

      If you reject a recommendation, you can modify the prompt and review the generated code recommendations once again to match your task intent.

  10. After you accept the code recommendation, click the ANSIBLE tab to see the content source matching results.

    For each generated code recommendation, Red Hat Ansible Lightspeed lists content source matches, including details such as potential source, content author, and relevant licenses. You can use this data to gain insight into potential training data sources used to generate the code recommendations.

  11. Click Save to save the code recommendation changes in your Ansible YAML file.

The Red Hat Ansible Lightspeed with IBM watsonx Code Assistant machine learning model is trained on the following content:

  • Existing public or private Git repositories
  • Content from Ansible Galaxy

IBM watsonx Code Assistant uses generative AI technology and various types of Ansible content to train the model. Therefore, it is not possible to trace the specific training data that produced a given code recommendation.

For each generated code recommendation, Red Hat Ansible Lightspeed lists the content source matches, including details such as potential source, content author, and relevant licenses. You can use this data to gain insight into potential training data sources used to generate the code recommendations.

After you enter a natural language prompt in VS Code and see the generated code recommendations, you can view the content source matches on the ANSIBLE: LIGHTSPEED TRAINING MATCHES tab.

For example, the following illustration shows the training matches for the multitask recommendation Install postgresql-server & run postgresql-setup command:

Figure 5.3. Training matches for a multitask recommendation

Training matches for multitask recommendation

This capability enables you to find out the open source license terms that are associated with related training data. However, it is unlikely that either the training data used in fine-tuning the code or the output recommendations themselves are protected by copyright, or that the output reproduces training data that is controlled by copyright licensing terms.

Note

Red Hat does not claim any copyright or other intellectual property rights in the suggestions generated by Red Hat Ansible Lightspeed with IBM watsonx Code Assistant.

Using the Ansible VS Code extension, you can create Ansible playbooks using a natural language interface in English.

Red Hat Ansible Lightspeed with IBM watsonx Code Assistant reads the natural language prompts and generates an entire playbook recommendation based on your intent. You can also view the explanations for new or existing playbooks. The playbook explanations describe what the playbook does and contextualize its impact.

These capabilities enable Ansible developers to use natural language prompts to create new Ansible playbooks quickly and more efficiently and also get an explanation for existing Ansible playbook, thereby reducing the overall onboarding learning period. For information about Ansible playbooks, see the Getting started with Ansible Playbooks guide.

Note

You can create playbooks and view playbook explanations when connecting to the Red Hat Ansible Lightspeed cloud service and on-premise deployments.

5.4.1. Best practices to create playbooks

Follow these guidelines for the highest quality of a playbook recommendation.

  • Ensure that the goal statements directly specify what the playbook must do.

    Your statement should start with the goal of the playbook, for example, Apply security patches to RHEL9. Avoid starting statements with Create a playbook that, Please prepare a playbook that, or I need help with.

  • Ensure that the goal statement does not contain new lines.
  • Ensure that the goal statement is not more than one sentence.

    You might have to repeat the details in the goal statement to produce the best results. It is recommended that you use the generated outline as feedback about whether your goal statement might benefit from more or less details, and then modify the goal statement as necessary.

  • Ensure the following when you edit the outline:

    • Do not restate the goal of the playbook.
    • Verify that the steps considered capture the key steps in the playbook. The steps need not reflect each and every task that is expected in the playbook.
    • Keep the step description in one sentence without adding new lines to the outline.

5.4.2. Generating Ansible playbooks

You can use the natural language interface in the Ansible VS Code extension to generate an entire Ansible playbook.

Prerequisites

  • You meet one of the following requirements:

    • Your organization has a trial or paid subscription to both the Red Hat Ansible Automation Platform and IBM watsonx Code Assistant.
    • Your organization has a trial or paid subscription to the Red Hat Ansible Automation Platform, and you have a Red Hat Ansible Lightspeed trial account.
  • You have installed and configured the Ansible VS Code extension.

Procedure

  1. Log in to VS Code with your Red Hat account.
  2. From the Activity bar, click the Ansible icon.
  3. Under Ansible Creator, click Get started. The Ansible Content Creator page is displayed.

    The following illustration displays the Ansible Content Creator page:

    Figure 5.4. Settings to create Ansible playbooks

    Settings to create Ansible playbooks
  4. Select the Playbook with Ansible Lightspeed tile. The Create a playbook page is displayed.
  5. In the What do you want the playbook to accomplish? field, enter the prompts to create a playbook and click Analyze.

    After a few seconds, the recommended steps for your playbook intent are displayed in the Review the suggested steps for your playbook and modify as needed field.

  6. Perform one of the following tasks:

    • If the steps match your intent: Click Generate Playbook.
    • If any modifications are required: Click the editor and update the tasks or steps to suit your intent.
    • If the task suggestions do not match your intent: Click Back to change the original prompt and start over.
    • If you want to restore the original task suggestions: Click Reset and proceed to the next step.
  7. After you verify the steps, click Generate playbook.

    It takes a few seconds for the playbook to generate, and The following playbook was generated for you field displays the newly generated playbook.

  8. Click Open editor. The generated playbook opens as an untitled YAML file in the VS Code editor.
  9. Save the untitled YAML file.

5.4.3. Viewing the playbook explanations

You can request explanations for a newly created playbook as well as an existing Ansible playbook.

Prerequisites

  • You meet one of the following requirements:

    • Your organization has a trial or paid subscription to both the Red Hat Ansible Automation Platform and IBM watsonx Code Assistant.
    • Your organization has a trial or paid subscription to the Red Hat Ansible Automation Platform, and you have a Red Hat Ansible Lightspeed trial account.
  • You have installed and configured the Ansible VS Code extension.
  • You have opened the playbook whose explanation you want to view.

Procedure

  1. Log in to VS Code with your Red Hat account.
  2. Open an Ansible playbook YAML file in VS Code.
  3. Use one of the following methods to view the playbook explanation:

    • From an active playbook YAML file:

      1. Place your cursor anywhere within the playbook file.
      2. Right-click and select Explain the playbook with Ansible Lightspeed.
    • From the Ansible panel:

      1. From the navigation menu, click the Ansible icon.
      2. Select Explain the current playbook.

        The playbook explanation is displayed on the right panel of the VS Code screen.

        The following illustration shows an example of a playbook explanation:

        Figure 5.5. Example of a playbook explanation

        Example of a playbook explanation

5.5. Creating roles and viewing role explanations

You can create roles within Ansible collections using the Ansible VS Code extension. To create roles, use the Ansible VS Code extension, select the Role Generation option, and then enter the natural language prompts in English language. Red Hat Ansible Lightspeed reads the natural language prompts and creates a role recommendation based on your intent. You can also view the explanations for new or existing roles. The role explanations describe what the role does and contextualize its impact.

These capabilities enable Ansible developers to use natural language prompts to create Ansible roles quickly and more efficiently, as well as get an explanation for existing Ansible roles. In addition to generating playbooks, role generation can now further reduce your team’s overall onboarding learning period. For information about Ansible roles, see Bundle content with Ansible roles in the Getting started with Ansible Automation Platform guide.

Note

You can create roles and view role explanations when connecting to the Red Hat Ansible Lightspeed cloud service only.

5.5.1. Creating roles within collections

You can use the natural language interface in the Ansible VS Code extension to create one or more roles within an Ansible collection.

Prerequisites

  • You meet one of the following requirements:

    • Your organization has a trial or paid subscription to both the Red Hat Ansible Automation Platform and IBM watsonx Code Assistant.
    • Your organization has a trial or paid subscription to the Red Hat Ansible Automation Platform, and you have a Red Hat Ansible Lightspeed trial account.
  • You have installed and configured the Ansible VS Code extension v25.3.0 or later. For the procedure, see Installing and configuring the Ansible VS Code extension.
  • You have an existing Ansible environment configured with a valid collection directory within the Ansible VS Code extension.

Procedure

  1. Log in to VS Code with your Red Hat account.
  2. From the Activity bar, click the Ansible icon.
  3. Use one of the following methods to create a role:

    • From the Ansible panel:

      1. From the navigation menu, click the Ansible icon.
      2. Click Generate a role.
    • From the Command Palette:
    • From the Command Palette of the VS Code editor, click View Command Palette, and then enter > Ansible Lightspeed: Role generation.

      The Create a role with Ansible Lightspeed page is displayed on the right panel of the VS Code screen.

  4. From the Select the collection to create role in list, choose the collection where you want to create the role. You must have a collection inside your workspace to create a role.

    If you do not have a collection, you must create it by using one of the following methods:

    • By using the following command:

      ansible-creator init collection myns.mycollection my_directory

      After you run the command, open the new directory with VS Code.

    • By using the Ansible VS Code extension

      For more information, see the topic About content collections in the Getting started with Ansible Automation Platform guide.

  5. In the Describe what you want to achieve in natural language field, enter the prompts to create a role and then click Analyze.

    After a few seconds, the recommended steps for your role intent are displayed in the Review the suggested steps for your role and modify as needed field.

  6. Perform the following tasks:

    1. Review and optionally change the role name.
    2. Review the collection where the role will be created.
    3. Verify that the suggested steps match your intent and then click Continue.

      It takes a few seconds for the role to generate, and the newly generated role is displayed along with the list of files where the role was generated.

      Note
      • If you want to modify the steps: Click the editor field, update the prompts or steps to suit your intent, and then click Continue.
      • If the role suggestions do not match your intent: Click Back to change the original prompt and start over.
      • If you want to restore to the original suggested steps: Click Reset and then click Continue to proceed to the next step.
  7. Click Save files. A list of files is displayed that includes the new role.
  8. Click the files to open them in the VS Code editor directly.

5.5.2. Viewing the role explanations

You can request explanations for a newly created role as well as an existing Ansible role.

Prerequisites

  • You meet one of the following requirements:

    • Your organization has a trial or paid subscription to both the Red Hat Ansible Automation Platform and IBM watsonx Code Assistant.
    • Your organization has a trial or paid subscription to the Red Hat Ansible Automation Platform, and you have a Red Hat Ansible Lightspeed trial account.
  • You have installed and configured the Ansible VS Code extension v25.3.0 or later. For the procedure, see Installing and configuring the Ansible VS Code extension.
  • You have opened the role whose explanation you want to view in the VS Code editor.

Procedure

  1. Log in to VS Code with your Red Hat account.
  2. Open an Ansible role YAML file within the roles directory in VS Code.
  3. Use one of the following methods to view the playbook explanation:

    • From an active role YAML file:

      1. Place your cursor anywhere within the playbook file.
      2. Right-click and select Explain the role with Ansible Lightspeed.
    • From the Ansible panel:

      1. From the navigation menu, click the Ansible icon.
      2. Select Explain the current playbook.
    • From the Command Palette:

      • From the Command Palette of the VS Code editor, enter Explain the role with Ansible Lightspeed.

        The role explanation is displayed on the right panel of the VS Code screen.

        The following illustration shows an example of a role explanation:

        Figure 5.6. Example of a role explanation

        Example of a role explanation

5.6. Viewing the audit logs

The Ansible Visual Studio (VS Code) extension now records all Red Hat Ansible Lightspeed operations in an audit log for future use. Each interaction is recorded with a timestamp, the type of action performed, details of the requested task, and other relevant information.

The logs are displayed in the Ansible Lightspeed Output Channel of the VS Code editor and are available until you close VS Code.

Procedure

  1. Open VS Code.
  2. Open the Command Palette of the VS Code editor.
  3. Click Output Show Output Channels, and then select Ansible Lightspeed.

    An Output panel is displayed at the bottom of the VS Code editor with a log of all user actions.

    Following is an example of an audit log:

    Figure 5.7. Audit log

    Audit log

Red Hat Ansible Lightspeed with IBM watsonx Code Assistant is designed to be improved through feedback on the quality of its suggestions. The technical details of user experiences with Red Hat Ansible Lightspeed are useful in informing further improvements.

You can submit feedback through the following channels:

  • From the Ansible VS Code extension: Use this method to provide feedback about the quality of the suggested code recommendations.

    Important

    Red Hat Support cannot assist with the suggestion quality reports. Content quality issues are routed to IBM for resolution.

  • From the Red Hat customer portal: Use this method to log bug reports and service disruption incidents, and feature requests.

Prerequisites

Ensure that you meet one of the following requirements:

  • Your organization has a trial or paid subscription to both the Red Hat Ansible Automation Platform and IBM watsonx Code Assistant.
  • Your organization has a trial or paid subscription to the Red Hat Ansible Automation Platform, and you have a Red Hat Ansible Lightspeed trial account.

Procedure

  1. Open Visual Studio Code.
  2. Click the Lightspeed entry in your status bar to see options.
  3. In the Tell us why field, provide your feedback. Here, provide feedback about what results you were expecting to receive, compared to what results were generated and the training match.
  4. Select the issue type: Bug report, Feature request, or Suggestion feedback.

    Note

    To raise a bug or feature request, contact Red Hat Support and open a support ticket. Bug features and feature requests made through Ansible Lightspeed feedback are not tracked through the Red Hat Service Level Agreement (SLA).

  5. Select the I understand that feedback is shared with Red Hat and IBM checkbox.
  6. Click Send.

    The following image shows an example of providing suggestion feedback:

    Figure 5.8. Providing feedback on Ansible Lightspeed

    Providing feedback on Ansible Lightspeed
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2026 Red Hat
Back to top