Subscribe to our blog

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 blog, 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.

Commercial features: 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 feature, teams can build more confidence in their automation code base.

Illustration of the three components in Red Hat Ansible Lightspeed with IBM watsonx Code Assistant

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.

In the next steps, we will explain how you can set up and start using Ansible Lightspeed with watsonx Code Assistant.

Subscribe to IBM watsonx Code Assistant for Ansible Lightspeed

In order to experience 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.

Logging in and configuring Red Hat Ansible Lightspeed to connect to IBM watsonx Code Assistant

Note: This section is only intended for someone with organization administrator privileges on the Red Hat customer portal account for your organization. If that’s not you, move on to the next section on how to get connected in 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.

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

Prerequisites

  • You have organization administrator privileges to a Red Hat Customer Portal organization with a valid Ansible Automation Platform subscription.
  • You have obtained a WxCA API key and a model ID of the IBM watsonx Code Assistant that you want to use in 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.
    1. The Red Hat Ansible Lightspeed service uses Red Hat Single Sign-On (SSO) for authentication.
    2. As part of the authentication process, the Red Hat 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.
  4. From the login screen, click Admin Portal.
    1. 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.

  5. Specify the API key of your IBM watsonx Code Assistant instance and Click Save.
    1.  Optional: Click Test to validate the API key

  6. Specify the model ID of the model that you want to use and click Save.
    1. Optional: Click Test to validate model ID.

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

And just like that, users in your Red Hat Account will now have access to Ansible Lightspeed with the watsonx Code Assistant service.

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

Getting connected: 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 Red Hat 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.

Log in using your Red Hat credentials

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.
Installing the Ansible Visual Studio Code extension

Log in using your Red Hat credentials

Congratulations! You’ve successfully configured Ansible Lightspeed with watsonx Code Assistant in VS Code.

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

Screenshot of the VS Code status bar

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 with Red Hat Ansible Lightspeed

Now that you are connected to Ansible Lightspeed with watsonx Code Assistant, it's time to experience its AI-enhanced content creation experience.

Let’s use an example Playbook to walk through asking Red Hat Ansible Lightspeed for AI-generated task suggestions and also highlight some of what you can expect from commercial features. The example playbook installs and configures PostgreSQL on all machines of the database host group.

Note: As part of our ongoing improvements to the service, IBM and Red Hat will keep pushing updates to improve the quality of recommendations. Therefore, Ansible task suggestions in the examples below may differ.

How do I generate a Red Hat Ansible Lightspeed suggestion?

Let’s use our first Playbook task in the configure_postgres.yml example Playbook to demonstrate asking Ansible Lightspeed with watsonx Code Assistant for an AI suggestion.

  • Move your cursor to the end of the “- name: Install postgresql-server” task description.
  • Press "ENTER" to generate a suggestion.
  • Press "TAB" to accept the suggestion.
Generating an Ansible task

Generating an Ansible task

In this suggestion we asked the service to install “postgresql-server” package, the suggestion used the Fully Qualified Collection Name (FQCN) - ansible.builtin.package to reference the Ansible module to manage generic OS packages.

Using FQCNs is a recommended best practice and an example of the many unique post-processing capabilities we’ve baked into the Red Hat Ansible Lightspeed service.

Let’s move on to the next tasks.

How do I generate multiple task suggestions?

Now that we have got a suggestion back from the service to “Install postgresql-server”, we need to ask some more suggestions from the service to configure PostgreSQL, like

  • Run postgresql-setup command
  • Start and enable postgresql service
  • Allow the postgres traffic through the firewall

One option would be to follow the single-task mechanism to get recommendations for each task like we did in the above section.

An exciting  new commercial feature of Ansible Lightspeed with watsonx Code Assistant is multi-task generation. A step on the roadmap towards full Playbook generation, multi-task generation allows you to generate multiple tasks with a single prompt entry, by chaining multiple tasks descriptions using ampersand(&) sign in a YAML comment at the task level.

Let’s use our same Playbook example and demonstrate asking the service for multi-task suggestions. We have already created a YAML comment in this file. If you look closely on line 12, you will see that we have chained the different tasks to configure PostgreSQL with ampersands (&) in a YAML comment at the task level.

  • Move your cursor to the end of the line “# Run postresql-setup command & Start and enable postgresql service & Allow the traffic”, which is a YAML comment.
  • Press "ENTER" to generate a suggestion with multiple.
  • Press "TAB" to accept the suggestion.
Generating multiple Ansible tasks

Generating multiple Ansible tasks

In the same Playbook, this time we asked for multiple suggestions together to “Run postgresql-command”, “Start and enable postgresql service” and “Allow the traffic”. The suggestion returned three Ansible tasks in the suggestion this time.

Generating contextually aware, accurate Ansible content suggestions saves you time and helps you create efficiently. One of Red Hat Ansible Lightspeed’s superpowers is context. The last task just asks to “Allow the traffic”, which might seem counterintuitive as an AI “ask”, but the Red Hat Ansible Lightspeed service is aware of the Ansible Playbook it's working in and suggests a port suggestion to open which corresponds to the default port for PostgreSQL(5432).

Note: This is just an example to show a capability of Ansible Lightspeed with watsonx Code Assistant to the readers. When writing Ansible content, we recommend being explicit in the task names so it’s easy for anyone to understand your Ansible content.

Let’s move on to the next feature.

Adopt with built-in transparency: 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.

Ansible Lightspeed Content Source Matching

Ansible Lightspeed Content Source Matching

Adopt with Ansible best practices and more accuracy

Red Hat Ansible Lightspeed is solely focused on automation, which provides a streamlined and accurate generative AI experience that is tailored by—and for—IT automation teams.  With post-processing capabilities that adhere to accepted best practices, automation teams can have confidence in the code they are accepting.

The post-processing capabilities of Red Hat Ansible Lightspeed enhance the Ansible content recommendations from IBM watsonx Code Assistant for best practices. For instance, using FQCN, doing data anonymization and variable substitutions among other things.

The example 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.

Adopt with model customization (fine-tuning)

A long-awaited feature of Ansible Lightspeed with watsonx Code Assistant, model customization is also now available. Model customization allows Ansible Lightspeed users to leverage their existing Ansible content to train the watsonx Code Assistant generative AI 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 IBM 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. We will do a deep-dive of the whole process in the future blogs.

Maintain: Ansible code bot (Services Preview)

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.
Ansible Code bot in action

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.

Note: Service Preview is the initial release “phase” for a Cloud Service. Service Previews are made available to selected internal and external customers to gather initial feedback on a service, but not for production usage. In addition, individual features of a Cloud Service in the Field Trial, Limited Availability, or General Availability phase can be documented as Service Preview, meaning the feature is not for production use.

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.

For more information on next steps, check out the Red Hat Ansible Lightspeed homepage, where there are links for existing Red Hat customers and those interested in trying Ansible Automation Platform. For more insight on IBM’s Ansible-specific foundation model, check out the IBM watsonx Code Assistant website.

Plus, explore these features: 

We’ll keep the blogs, videos and other resources coming as this service evolves to help you get the most out of generative AI - the Ansible way.

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

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