Develop and execute projects in Dev Spaces

OpenShift Dev Spaces provides a web-based Integrated Development Environment that includes the Ansible VS Code extension and command line tools. You can use this environment to develop and test your automation code.

About this task

The OpenShift Dev Spaces instance provides a default configuration that installs the Ansible VS Code extension and provides the Ansible command line tools.

Procedure

Activate Ansible Lightspeed in the Ansible VS Code extension. For more information, refer to the Red Hat Ansible Lightspeed with IBM watsonx Code Assistant User Guide.
Important

OpenShift Dev Spaces is not included with your Ansible Automation Platform subscription or the Ansible plug-ins for Red Hat Developer Hub.

Execute automation tasks in Dev Spaces

The default configuration for Dev Spaces provides access to the Ansible command line tools.

Procedure

To execute an automation task in Dev Spaces from the VSCode user interface:
  1. Right-click a playbook name in the list of files.
  2. Select Run Ansible Playbook via ansible-navigator run or Run playbook via ansible-playbook.
    Run a playbook from VS Code

Connect your project to Ansible Automation Platform

Access Ansible Automation Platform through the Red Hat Developer Hub to create a project for your playbook repository, then set up a job template that uses the playbook. You can go directly to your automation controller instance if it was not configured during the plug-in installation.

Procedure

  1. The Ansible plug-ins provide a link to Ansible Automation Platform.
  2. Log in to your Red Hat Developer Hub UI.
  3. Click the Ansible A icon in the Red Hat Developer Hub navigation panel.
  4. Click Operate to display a link to your Ansible Automation Platform instance.

    If automation controller was not included in your plug-in installation, a link to the product feature page is displayed.

  5. Click Go to Ansible Automation Platform to open your platform instance in a new browser tab.

    Alternatively, if your platform instance was not configured during the Ansible plug-in installation, navigate to your automation controller instance in a browser and log in.

  6. Log in to automation controller.
  7. Create a project in Ansible Automation Platform for the GitHub repository where you stored your playbook project. Refer to Projects for more information.
  8. Create a job template that uses a playbook from the project that you created. Refer to Workflow job templates for more information.

Example: Automate a Red Hat Linux firewall configuration

This example demonstrates how the Ansible plug-ins can help Ansible users of all skill levels create quality Ansible content.

As an infrastructure engineer new to Ansible, you have been tasked to create a playbook to configure a Red Hat Enterprise Linux (RHEL) host firewall.

The following procedures show you how to use the Ansible plug-ins and Dev Spaces to develop a playbook.

Learn more about playbooks

The first step is to learn more about Ansible playbooks using the available learning paths.

Procedure

  1. Click the Ansible A icon in the Red Hat Developer Hub navigation panel.
  2. Click Learn and select the Getting Started with Ansible Playbooks learning path. This redirects you to the Red Hat Developer website.
  3. If you are prompted to log in, create a Red Hat Developer account, or enter your details.
  4. Complete the learning path.