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
5.1. Accessing the Ansible Lightspeed portal as an automation developer Copy linkLink copied to clipboard!
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.
| Scenario | Result |
|---|---|
| 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. |
5.1.1. Logging in to the Ansible Lightspeed portal as an automation developer Copy linkLink copied to clipboard!
Use the following procedure to log into the Ansible Lightspeed portal with your Red Hat account.
Procedure
- Go to the Ansible Lightspeed portal login page.
-
Click
. 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.
5.1.2. Logging out of the Ansible Lightspeed Service Copy linkLink copied to clipboard!
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
. You will see a list of accounts that VS Code is logged into.
-
Select
.
-
Click the Person icon
Log out of the Ansible Lightspeed portal:
- Navigate to the Ansible Lightspeed portal login page.
- Click Log out.
5.2. Installing and configuring the Ansible VS Code extension Copy linkLink copied to clipboard!
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 Copy linkLink copied to clipboard!
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 Copy linkLink copied to clipboard!
Use the following procedure to install the Ansible Lightspeed extension in VS Code.
Prerequisites
- VS Code version 1.70.1 or later.
You can also install VScode derivatives, such as VScode Insider or VS Codium.
Procedure
- Open the VS Code application.
- From the navigation menu, click the Extensions icon.
- In the Search field, enter Ansible.
- Select Ansible to choose the Ansible language support extension published by Red Hat.
- Click Install.
After installation is complete, verify your VSCode installation:
-
Create a new YAML file using the
.ymlor.yamlfile extension. - From the Status toolbar, click the language indicator and select Ansible to associate the Ansible language type with the new YAML file.
- Start writing a test playbook. Contextual aids are displayed as you start creating your content.
-
Create a new YAML file using the
5.2.3. Configuring the Ansible VS Code extension Copy linkLink copied to clipboard!
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
- Open the VS Code application.
-
From the Activity bar, click the Extensions icon
.
- From the Installed Extensions list, select Ansible.
- From the Ansible extension page, click the Settings icon and select Extension Settings.
Select Ansible Lightspeed settings, and specify the following information:
Expand UI field Description 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.
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.
5.2.4. Logging in to Ansible Lightspeed through the Ansible VS Code extension Copy linkLink copied to clipboard!
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 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 menu. Follow the on-screen prompts to log in and access the Ansible Lightspeed service using your RH-SSO.
NoteIf you are using a cloud development environment at a domain unknown by Ansible Lightspeed, such as on-premise Red Hat OpenShift Dev Spaces, your 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
- Open the VS Code application.
Sign in using either the Connect button in the Ansible Lightspeed view or the menu.
Sign in using the Connect button:
- From the VS Code activity bar, click the Ansible icon.
- In the Ansible Lightspeed view, click Connect.
- Follow the on-screen prompts to sign in to Ansible Lightspeed.
Sign in using the menu:
- From the VS Code activity bar, click the menu.
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 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.
- 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.
5.2.5. Logging out of the Ansible Lightspeed Service Copy linkLink copied to clipboard!
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
. You will see a list of accounts that VS Code is logged into.
-
Select
.
-
Click the Person icon
Log out of the Ansible Lightspeed portal:
- Navigate to the Ansible Lightspeed portal login page.
- Click Log out.
5.3. Creating task recommendations Copy linkLink copied to clipboard!
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.
NoteCurrently, 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.1. Best practices to improve the recommended guidance Copy linkLink copied to clipboard!
Follow these guidelines to improve the likelihood of a quality code recommendation.
- Ensure that your YAML file is properly formatted. See the Ansible YAML syntax guidelines for details.
Avoid context switching within a single playbook file.
The Ansible Lightspeed service attempts to correlate earlier tasks to the active recommendation, and the entire contents of the file before the cursor position are used as context by the model. If the earlier task is not relevant to your prompt, VS code provides inline suggestions instead of code recommendations.
Reword your natural language prompts to get code recommendations that match your task intent.
If you get a recommendation that does not align with the intent of your task name, then rewording your prompt to provide more information about what is desired can lead to improved results.
Use descriptive prompts and provide additional content to improve the code recommendations.
Red Hat Ansible Lightspeed reads the full Ansible YAML file when generating a code recommendation. Using descriptive prompts and having additional YAML file content related to the desired task improves the code recommendation. For example, you can add the previous Ansible tasks and appropriate playbook and variable names to improve the code recommendations.
5.3.2. Creating single task recommendations Copy linkLink copied to clipboard!
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
- Log in to VS Code with your Red Hat account.
Create a new YAML file or use an existing YAML file:
Create a YAML file:
-
Select
. - From the lower right of the screen, click Plain Text, and in the language mode, select Ansible.
-
Save the file as a YAML file format extension (
.ymlor.yaml).
-
Select
Use an existing YAML file:
On the bottom right of the screen, click the existing language mode, and in the language mode settings, select Ansible.
NoteIf you do not see the language mode section in your VS Code editor, from the Command Palette, select
.
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
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:
-
From the Activity bar, click the Extensions icon
.
- From the Installed extensions list, select Ansible.
- From the Ansible extension page, click the Settings icon and select Extension Settings.
- Clear the Ansible › Validation › Lint: Enabled checkbox.
-
From the Activity bar, click the Extensions icon
Create a playbook or use an existing playbook.
For more information, see the Getting started with playbooks guide.
In the playbook, provide the following information to request code recommendations for a single task:
-
Add a new Ansible task by starting a new line with
- name:at the correct indentation. -
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 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.
ImportantAnsible 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.
-
Add a new Ansible task by starting a new line with
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:
Accept or reject the code recommendations:
- To accept a code recommendation, press Tab.
To reject a code recommendation, press Esc.
NoteIf you reject a recommendation, you can modify the prompt and review the generated code recommendations once again to match your task intent.
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.
- Click Save to save the code recommendation changes in your Ansible YAML file.
5.3.3. Creating multitask recommendations Copy linkLink copied to clipboard!
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
# Install postgresql-server & run postgresql-setup command
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
# 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
The Ansible Lightspeed service reads the text, interacts with the IBM watsonx Code Assistant model, and generates the code recommendations.
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
- Log in to VS Code with your Red Hat account.
Create a new YAML file or use an existing YAML file.
Create a YAML file:
-
Select
. - From the lower right of the screen, click Plain Text, and in the language mode, select Ansible.
-
Save the file as a YAML file format extension (
.ymlor.yaml).
-
Select
Use an existing YAML file:
On the bottom right of the screen, click the existing language mode, and in the language mode settings, select Ansible.
NoteIf you do not see the language mode section in your VS Code editor, from the Command Palette, select
.
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
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:
-
From the Activity bar, click the Extensions icon
.
- From the Installed extensions list, select Ansible.
- From the Ansible extension page, click the Settings icon and select Extension Settings.
- Clear the Ansible › Validation › Lint: Enabled checkbox.
-
From the Activity bar, click the Extensions icon
Create a playbook or use an existing playbook.
For more information, see the Getting started with playbooks guide.
In the playbook, provide the following information to request multitask code recommendations:
- Start a new YAML file comment by entering a pound symbol (#) at the correct indentation.
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
# Install postgresql-server & run postgresql-setup commandCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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
# 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 tableCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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.
ImportantAnsible 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.
- Optional: If multitask code recommendations are not being generated, log out of VS Code and log in again using your Red Hat account.
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: :
Accept or reject the code recommendations:
- To accept a code recommendation, press Tab.
To reject a code recommendation, press Esc.
NoteIf you reject a recommendation, you can modify the prompt and review the generated code recommendations once again to match your task intent.
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.
- Click Save to save the code recommendation changes in your Ansible YAML file.
5.3.4. Viewing the Ansible Lightspeed training matches Copy linkLink copied to clipboard!
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
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.
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.
5.4. Creating playbooks and viewing playbook explanations Copy linkLink copied to clipboard!
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.
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 Copy linkLink copied to clipboard!
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 withCreate a playbook that,Please prepare a playbook that, orI 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 Copy linkLink copied to clipboard!
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
- Log in to VS Code with your Red Hat account.
- From the Activity bar, click the Ansible icon.
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
- Select the Playbook with Ansible Lightspeed tile. The Create a playbook page is displayed.
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.
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.
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.
- Click Open editor. The generated playbook opens as an untitled YAML file in the VS Code editor.
- Save the untitled YAML file.
5.4.3. Viewing the playbook explanations Copy linkLink copied to clipboard!
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
- Log in to VS Code with your Red Hat account.
- Open an Ansible playbook YAML file in VS Code.
Use one of the following methods to view the playbook explanation:
From an active playbook YAML file:
- Place your cursor anywhere within the playbook file.
- Right-click and select Explain the playbook with Ansible Lightspeed.
From the Ansible panel:
- From the navigation menu, click the Ansible icon.
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
5.5. Creating roles and viewing role explanations Copy linkLink copied to clipboard!
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.
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 Copy linkLink copied to clipboard!
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
- Log in to VS Code with your Red Hat account.
- From the Activity bar, click the Ansible icon.
Use one of the following methods to create a role:
From the Ansible panel:
- From the navigation menu, click the Ansible icon.
- Click Generate a role.
- From the Command Palette:
From the Command Palette of the VS Code editor, click
, 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.
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_directoryAfter 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.
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.
Perform the following tasks:
- Review and optionally change the role name.
- Review the collection where the role will be created.
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.
- Click Save files. A list of files is displayed that includes the new role.
- Click the files to open them in the VS Code editor directly.
5.5.2. Viewing the role explanations Copy linkLink copied to clipboard!
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
- Log in to VS Code with your Red Hat account.
- Open an Ansible role YAML file within the roles directory in VS Code.
Use one of the following methods to view the playbook explanation:
From an active role YAML file:
- Place your cursor anywhere within the playbook file.
- Right-click and select Explain the role with Ansible Lightspeed.
From the Ansible panel:
- From the navigation menu, click the Ansible icon.
- 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
5.6. Viewing the audit logs Copy linkLink copied to clipboard!
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
- Open VS Code.
- Open the Command Palette of the VS Code editor.
Click
, 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
5.7. Providing feedback on the Ansible Lightspeed service Copy linkLink copied to clipboard!
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.
ImportantRed 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
- Open Visual Studio Code.
- Click the Lightspeed entry in your status bar to see options.
- 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.
Select the issue type: Bug report, Feature request, or Suggestion feedback.
NoteTo 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).
- Select the I understand that feedback is shared with Red Hat and IBM checkbox.
Click Send.
The following image shows an example of providing suggestion feedback:
Figure 5.8. Providing feedback on Ansible Lightspeed