Search

Chapter 5. Installing and configuring the Ansible VS Code extension

download PDF

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.

You can also use a custom, fine-tuned model if your organization administrator has created a custom model and has shared the model ID with you separately. Use the model-override setting in the Ansible VS Code extension to override the default model, and use the custom model instead. Using a custom model enables you to improve the code recommendation experience and tune the model to your organizational automation patterns. For example, if you are using Red Hat Ansible Lightspeed both as an organization administrator and a user, you can test the custom model for select Ansible users before making it available for all users in your organization. For more information, see Configuring custom models.

5.1. Installing the Ansible VS Code extension

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. Configuring the Ansible VS Code extension

You can configure the Ansible VS Code extension to enable Red Hat Ansible Lightspeed and specify it’s portal URL and IBM watsonx Code Assistant model ID.

Prerequisites

  • Your organization administrator has configured an IBM watsonx Code Assistant model for your organization.

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:

    1. Select the Enable Ansible Lightspeed checkbox.
    2. In the URL for Ansible Lightspeed field, verify that you have the following URL: https://c.ai.ansible.redhat.com/.
    3. Select the Enable Ansible Lightspeed with watsonx Code Assistant inline suggestions checkbox.
  6. Optional: If you want to use the custom model instead of the default model, in the Model ID Override field, enter the custom model ID. The model-override setting enables you to override the default model and use the custom model, after your organization administrator has created a custom model and has shared the model ID with you separately.

    Your settings are automatically saved in VS Code.

The following illustration displays the configured settings for the Ansible VS Code extension:

Figure 5.1. Configured settings for the Ansible VS Code extension

Configured settings for the Ansible VS Code extension

5.3. Logging in to Ansible Lightspeed through the Ansible VS Code extension

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

Procedure

  1. Open the VS Code application.
  2. Use one of the following ways to connect to the Ansible Lightspeed service.

    • Using the Connect button:

      1. From the navigation menu, click the Ansible icon.
      2. Under Ansible Lightspeed Login, click Connect.
    • Using the Accounts button:

      1. From the navigation menu, click Accounts icon > Sign in with Ansible Lightspeed.

        Note

        This option is 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.

  3. When prompted, click Allow to sign in.
  4. In the Authorize Ansible Lightspeed for VS Code window, click Authorize.
  5. In the Do you want Code to open the external website? window, click Open. The Ansible Lightspeed portal login page is displayed.
  6. Click Log in Log in with Red Hat.
  7. 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. The VS code extension is now connected with Ansible Lightspeed service.

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.

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.

© 2024 Red Hat, Inc.