Subscribe to the feed

Note from the editor: This blog post was originally published in November 2023 and has been updated by the author.

Last year, we launched Ansible Lightspeed with IBM Watson Code Assistant, a new generative AI service within Red Hat Ansible Automation Platform. Ansible Lightspeed with watsonx Code Assistant is engineered to help automation teams create, adopt, and maintain Ansible content more efficiently.

In this post, we’ll walk through the steps to get Ansible Lightspeed with IBM watsonx Code Assistant up and running for your organization. We’ll share how end users can set up the service in their Visual Studio Code (VS Code) environment. We’ll also share more on what to expect from the experience and supplemental tools available to turbocharge your Ansible creator journey with generative AI capabilities built on a foundation of transparency, accuracy, and choice.

This is an exciting addition to the Ansible Automation Platform experience, so let’s kick things off.

Bringing AI to Ansible content creation through collaboration between Red Hat and IBM

Ansible Lightspeed with watsonx Code Assistant is the culmination of Red Hat and IBM teams combining forces to create a cohesive AI experience for Ansible content creation. Tapping into automation-specific IBM watsonx foundation models, it turns text prompts into Ansible content snippets for the creation of Ansible content. The generated content adheres to accepted Ansible best practices and,  when combined with the Ansible code bot, helps teams build more confidence in their automation code base.

Ansible lightspeed layer

The service consists of three components:

  1. The developer interface - Built natively into the VS Code extension via the Ansible extension, this allows Ansible content creators to use natural language prompts in the Ansible Playbooks or task files to generate Ansible Lightspeed single and multi-task suggestions.
  2. The integrated service - This acts as the glue or broker between the developer interface and the watsonx.ai service. It brings the power of AI to Ansible Automation Platform and enhances the responses from the AI with its post-processing capabilities.
  3. The AI - IBM watsonx Code Assistant provides access to Ansible-specific watsonx.ai foundation model that generates Ansible content recommendations. This is the “AI guts'' of the solution.

Ansible Lightspeed with watsonx Code Assistant can be deployed as a software-as-a-service (SaaS) deployment or on-premise in your datacenter. 

Subscribe to Ansible Lightspeed with watsonx Code Assistant - SaaS deployment

In order to connect to the SaaS version of Ansible Lightspeed with watsonx Code Assistant, you must:  

  1. Have an active Ansible Automation Platform subscription OR
  2. Sign up for a trial subscription to Ansible Automation Platform.

AND 

  1. Sign up for IBM watsonx Code Assistant by choosing from one of their subscription packages.

Note: Current IBM watsonx Code Assistant subscribers and Ansible Automation Platform customers should follow these instructions for connecting Ansible Lightspeed to watsonx Code Assistant. 

After completing the steps in your IBM Cloud account, you will get access to a IBM watsonx Code Assistant (WxCA) API key and Model ID which can then be used to connect the Ansible Lightspeed service to your IBM watsonx Code Assistant instance.

Subscribe to IBM watsonx Code Assistant for Ansible Lightspeed - On-premise

For organizations in sensitive industries with data privacy requirements or air-gapped environments, both the Ansible Lightspeed service and the watsonx Code Assistant large language model are now available for on-premise deployment. This enables Ansible Automation Platform customers more control over their data and supports compliance with enterprise security policies.

In order to connect the Ansible Lightspeed service on-premise, you will need:

  1. Ansible Automation Platform 2.4 or greater
  2. Red Hat Openshift to run the Ansible Lightspeed service

In order to connect watsonx Code Assistant on-premise, you will need:

  1. IBM watsonx Code Assistant (WCA) on-premise and hosted on Cloud Pak for Data.
  2. For other system requirements and pricing for on-premise deployments of watsonx Code Assistant, please contact IBM.

Logging in and connecting  Ansible Lightspeed to watsonx Code Assistant

NOTE: This section is intended for organization administrators with privileges to the Red Hat customer portal account for your organization. For all other users, jump to the next section for instructions on connecting the VS Code extension for Ansible.

As Red Hat customer portal administrator, you must configure Red Hat Ansible Lightspeed to connect to your IBM watsonx Code Assistant instance. This configuration enables Red Hat Ansible Lightspeed to communicate with your IBM watsonx Code Assistant instance.

You need the following IBM watsonx Code Assistant information to connect Red Hat Ansible Lightspeed:

  • IBM watsonx Code Assistant (WxCA) API key
    • A WxCA API key authenticates all requests made from Red Hat Ansible Lightspeed to IBM watsonx Code Assistant. Each Red Hat organization with a valid Ansible Automation Platform subscription must have a configured WxCA API key. When an authenticated Red Hat Single Sign-On (SSO) user queries Red Hat Ansible Lightspeed for a suggestion, the WxCA API key associated with the user’s Red Hat organization is used to authenticate the request to IBM watsonx Code Assistant.
  • Model ID
    • A unique WxCA model ID identifies an IBM watsonx Code Assistant model in your IBM Cloud account. The model ID that you configure in the Red Hat Ansible Lightspeed administrator portal is used as the default model, thus it will be used to get suggestions from Ansible Lightspeed for all the users in your organization who are assigned a seat.. This single-tenant IBM watsonx Granite model is unique to your organization and your organization only, to help with data privacy, compliance, and security. These models are provided, managed and maintained by IBM.

NOTE: You must configure both the WxCA API key and the model ID when you are initially configuring Red Hat Ansible Lightspeed.

Procedure

  1. Log in to the Ansible Lightspeed portal as an organization administrator.
  2. Click Log in > Log in with Red Hat.
  3. Enter your Red Hat account username and password.

The Ansible Lightspeed service uses Red Hat Single Sign-On (SSO) for authentication.

As part of the authentication process, the Ansible Lightspeed service checks whether you are an organization administrator and whether your organization has a valid Ansible Automation Platform subscription. On successful authentication, the login screen is displayed along with your username and your assigned user role.

  1. From the login screen, click Admin Portal. You are redirected to the Ansible Lightspeed with watsonx Code Assistant administrator portal that you can use to connect Red Hat Ansible Lightspeed to your IBM watsonx Code Assistant instance.
  2. Specify the API key of your IBM watsonx Code Assistant instance and vlick Save.

    Optional: Click Test to validate the API key

  3. Specify the model ID of the model that you want to use and click Save.

    Optional: Click Test to validate model ID.

When the WxCA API key and model ID is successfully validated, Ansible Lightspeed is connected to your IBM watsonx Code Assistant instance.

NOTE: As an organization administrator for your Red Hat account, you can create and manage users. Follow this link to learn more.

Installation and configuration

Prerequisites

  • Visual Studio Code and Ansible installed on your workstation
  • A Red Hat customer portal account (that is attached to your organization)

Procedure

  • Install the Ansible VS Code extension from the Visual Studio Code Marketplace by searching for "ansible" and selecting the extension published by Red Hat. Minimum version for Ansible extension to work with Ansible Lightspeed service is 2.8.108, check version history here.
  • Enable the Red Hat Ansible Lightspeed service within the extension by accessing the "Extension Settings" via the gear icon.
  • In the settings, enable both "Ansible Lightspeed enabled" and "Enable Ansible Lightspeed with Watson Code Assistant inline suggestions" checkboxes.

NOTE: You can enable Ansible Lightspeed in the “User” or “Workspace” settings, based on your preference. More information on VS Code User and Workspace settings can be found in their documentation.

vs code install optimized

Installing the Ansible Visual Studio Code extension

  • Click on the Ansible "A" in the VS Code activity bar on the left-hand side of your editor to open the extension.
  • Click "Connect" and follow the prompts to log into your Red Hat account using your credentials.
  • Next, authorize Ansible Lightspeed for VS Code by clicking “Authorize”.
  • Follow the browser prompts to redirect you back to VS Code, and, finally, click “Open” in the VS Code confirmation dialog box.
login

Log in using your Red Hat credentials

You can confirm that Ansible Lightspeed is enabled by checking the VS Code status bar at the bottom of the editor window.

Please ensure a Python environment is selected and your Ansible YAML files are associated with the Ansible language. More information on VS Code languages can be found in their documentation.

Create

Now that you are connected,  it's time to experience its AI-enhanced content creation experience.

Create an Ansible Playbook

Ansible Lightspeed with watsonx Code Assistant supports full playbook generation and content explanation. You will need to install the latest version of the Ansible VS Code extension (>=24.8.0) to access these features.

To get started, click on the Ansible icon in the left-hand navigation and then the ‘Get Started’ button under the Ansible Content Creator. Select “Playbook Generation with Ansible Lightspeed” to enter the guided chat interface for full playbook generation.

In the interface, enter your playbook prompt in natural language and click “Analyze”. The service will provide an editable outline of tasks (pseudo code). This chat-like interface allows real-time interaction with the generative AI service where you can refine your prompt. Both the playbook goal and outline are sent to Ansible Lightspeed with watsonx Code Assistant, which suggests a complete playbook. This intuitive and guided experience helps novice to intermediate users generate full Ansible Playbooks using generative AI.

Content explanation

Ansible VS Code extension also provides you capability to explain existing and newly generated playbooks so that you can easily understand the details of any playbook. To explain any playbook, open it in VS Code and click on ‘Explain the current playbook’ under the Ansible Lightspeed section. You can also right-click on a playbook and click on “Explain the playbook with Ansible Lightspeed”.

playbook generation

Ansible Lightspeed full playbook generation and explanation.

Along with full playbook generation and playbook explanation, Ansible Lightspeed also provides more granular control over the creation process through features like single and multi-task generation.

Single and multiple task generation

When you need to add specific inline tasks to your playbooks, Ansible Lightspeed excels with its single and multi-task generation capabilities.

Single Task Generation:

  • Start a new task in your playbook and provide a name using the name argument.
  • Position your cursor at the end of the task name and hit “ENTER” to get a suggestion from Ansible Lightspeed.

Multi-task Generation:

  • Create a comment line at the task block level in your playbook.
  • Chain multiple natural language prompts together using ampersands (&).
  • At the end of the comment line, hit “ENTER” to get a multi-task suggestion from Ansible Lightspeed.

These features streamline the process of creating detailed, multi-step workflows in your Ansible Playbooks, enhancing efficiency and consistency.

single task


Generating an Ansible task.
 

multi task

Generating multiple Ansible tasks.

Adopt

Content source matching

Another critical feature of Ansible Lightspeed with watsonx Code Assistant is transparency and openness using content source matching. We transparently share the potential source, author, and content license of the training data used for the recommendation. Building trust in the community and supporting the relationships between authors and contributors is part of Red Hat’s DNA.

content source matching optimized

Ansible Lightspeed content source matching

Post-processing

Ansible Lightspeed is purpose-built for automation, providing a streamlined and accurate generative AI experience that is tailored by—and for—IT automation teams. Ansible Lightspeed's post-processing capabilities adhere to accepted Ansible best practices so automation teams can have confidence in the code they are accepting.

Examples of post-processing include using FQCN, doing data anonymization, and other variable substitutions. The example provided in the “How to generate a suggestion” section above showed the suggestions generated with FQCNs as one of the post-processing capabilities of the service.

Maintain

Model customization (fine-tuning)

Model customization allows Ansible Lightspeed users to leverage their existing Ansible content to train the model. This feature can help to improve the quality and accuracy of your Ansible content with code recommendations that are more tailored to your organizations' specific needs and automation patterns.

At a high level, there are two steps to this process. The first step is to create a training dataset in a format that can be consumed by watsonx Code Assistant to create a custom model. The second step is to feed the training data to the generative AI model in the IBM Cloud console through the Watson Studio on IBM watsonx. Sticking to the collaborative approach between Red Hat and IBM, Red Hat has created a command-line tool to cover the first step of the process called ansible-content-parser.

Ansible code bot

Customers often ask, “we have the code, but what's next”? How do we move from siloed automation? How do we create a community of practice? Our answer starts with culture, and treating infrastructure workflows as software assets catalyzes the collaborative approach needed for enterprise-level automation. However, this could involve learning new skills like version control, automated testing, and code review.

Our goal with Ansible code bot is to extend Ansible content quality improvement beyond creation and into your entire workflow. The Ansible code bot scans existing Ansible Content Collections, roles, and playbooks hosted in GitHub repositories, and proactively creates pull requests whenever best practices or quality improvement recommendations are available. The bot automatically submits pull requests to the repository, which proactively alerts the repository owner to a recommended change to their content. You can configure Ansible code bot to scan your existing Git repositories (both public and private).

Prerequisites

  • A Red Hat customer portal account that is attached to your organization.
  • Your organization should have a valid Ansible Lightspeed with watsonx Code Assistant subscription enabled.

Procedure

  1. Log in to your GitHub by using an account associated with your organization.
  2. Install the GitHub app for the organization that you are a member of.
  3. Go to the Ansible code bot GitHub app:
    1. https://github.com/apps/ansible-code-bot
  4. Select the repositories on which you want to install the Ansible code bot.
  5. Click Install & Authorize.
  6. When prompted, log in to your Red Hat SSO account.
code bot optimized

Ansible code bot in action

After the Ansible code bot is installed for the Git repositories you selected, you can configure a schedule to scan your Git repositories at regular intervals. You can also manually scan your Git repositories by adding a topic called “ansible-code-bot-scan” to your repository, if you have not set up a scanning schedule for your Ansible code bot or if you do not want to wait for the next scheduled scan.

Wrap-up

Congratulations! You have successfully configured Ansible Lightspeed with watsonx Code Assistant for your organization. You’ve also put some exciting new generative AI capabilities to work with just a few simple steps.

Explore these other resources

Thanks for reading and happy automating. 


About the author

Anshul is a Principal Marketing Manager at Red Hat, where he brings his software development and QE experience to increase Ansible Automation Platform's adoption experience for customers by producing technical content on all aspects of the product.

Read full bio
UI_Icon-Red_Hat-Close-A-Black-RGB

Browse by channel

automation icon

Automation

The latest on IT automation for tech, teams, and environments

AI icon

Artificial intelligence

Updates on the platforms that free customers to run AI workloads anywhere

open hybrid cloud icon

Open hybrid cloud

Explore how we build a more flexible future with hybrid cloud

security icon

Security

The latest on how we reduce risks across environments and technologies

edge icon

Edge computing

Updates on the platforms that simplify operations at the edge

Infrastructure icon

Infrastructure

The latest on the world’s leading enterprise Linux platform

application development icon

Applications

Inside our solutions to the toughest application challenges

Original series icon

Original shows

Entertaining stories from the makers and leaders in enterprise tech