How to use Generative AI to enhance your automation coding productivity
Red Hat Ansible Lightspeed with IBM watsonx Code Assistant
What is IBM Watsonx?
Watsonx is an AI and data platform with three core components and a set of AI assistants designed to help you scale and accelerate the impact of AI with trusted data across your business.
The core components of watsonx include a studio for new foundation models, generative AI, and machine learning; a fit-for-purpose data store built on an open data lakehouse architecture; and a toolkit, to accelerate AI workflows that are built with responsibility, transparency, and explainability.
What are the foundation models?
Well, basically foundation models are the enterprise grade trustworthy large language models!
What is Red Hat Ansible Lightspeed?
‘Red Hat’ Ansible Lightspeed with IBM watsonx Code Assistant is a generative AI service engineered to help your automation teams create, adopt, and maintain Ansible content more efficiently. Connected to IBM watsonx Code Assistant, Red Hat Ansible Lightspeed helps you turn your automation ideas into Ansible code with natural language prompts.
As a ‘Red Hat’ Ansible Automation Platform component, Red Hat Ansible Lightspeed is accessed directly in Visual Studio Code via the Ansible extension.
So what are the features and what can you expect?
- Task generation: Generates a task for an Ansible Playbook or Role from a natural language prompt.
- Multitask generation: Generates multiple Ansible task suggestions for Ansible Task files and Playbooks by providing a sequential chain of natural language task prompts chained together using ampersands (&) in YAML comment (#) lines.
- Content source matching: Attempts to match each generated code snipped recommendation to the top 3 closest potential data training sources, including the Ansible content, content authors, and content licenses.
- Ansible code bot (technology preview mode as of publishing this article’s date): Scans existing content collections through selected Git repositories and automatically submits pull requests that can be qualitatively improved with the most up-to-date Ansible best practices.
- Post-processing rules: Augments generated code recommendations to ensure they adhere to Ansible best practices.
So basically it generates content, enhances productivity, and democratizes automation.
Okay, that’s nice, but how to use it?
How to use ‘Red Hat Ansible Lightspeed with IBM watsonx Code Assistant’?
Very simple, just follow the steps as provided hereafter.
- I assume you are using Microsoft Visual Studio Code either on MacOS or Windows.
- Install Red Hat’s ‘Ansible’ extension from the extensions library.
- Select the ‘Extension Settings’ gear.
- Set the URL for Ansible Lightspeed (https://c.ai.ansible.redhat.com).
- Open the above URL with your browser and log into the site either with a ‘Red Hat’ id or by using a GitHub ID.
- Verify the status inside Visual Code by choosing the ‘Ansible’ in left side vertical toolbar.
- Yor are all set. Let’s try it.
Let’s say I begin with an Ansible YAML file such as the one below;
---
- name: Httpd podman
hosts: all
tasks:
# Assert ansible_user is not root &
# Install podman &
# Pull httpd container image &
# Create httpd container
And I want to achieve a result by the extension. I put the video which shows how it works.
Hereafter my output file;
---
- name: Httpd podman
hosts: all
tasks:
# Assert ansible_user is not root &
# Install podman &
# Pull httpd container image &
# Create httpd container
- name: Assert ansible_user is not root
ansible.builtin.fail:
msg: '"ansible_user is not root"'
when: not ansible_user == "root"
- name: Install podman
ansible.builtin.package:
name: podman
state: latest
- name: Pull httpd container image
containers.podman.podman_image:
name: docker.io/library/httpd
- name: Create httpd container
containers.podman.podman_container:
name: testhttpd
image: httpd
state: started
detach: true
exposed_ports:
- 80
ports:
- 8080:80
volumes: /tmp/:/data
That’s all for today, thanks for reading this and stay tuned.