Chapter 4. Developing automation content in your workspace


The Ansible development tools are installed as part of the Ansible extension in the Ansible development workspace. You can use Ansible development tools to scaffold directories for automation content in your repository.

Using the Ansible extension ensures that best practices for directory structure are met. For more information about using the Ansible extension to develop automation content, refer to Developing automation content.

Red Hat recommends that you create only one collection per repository, so that each collection has a clear, specific purpose. This approach promotes reusability, as each collection is a self-contained unit of content. A one-to-one relationship between a collection and its repository also improves manageability by simplifying dependency management, maintenance, and release cycles.

Use the Ansible extension in VS Code to use Ansible development tools to scaffold directories and files for your automation content. You can use Red Hat Ansible Lightspeed with IBM watsonx Code Assistant to help you write playbooks, and ansible-lint to debug them.

Procedure

  1. In the OpenShift Dev Spaces dashboard. select the Ansible development workspace where you want to develop automation content.
  2. In the Activity bar of VS Code, select the Ansible icon to open Ansible development tools.
  3. Select Connect in the Ansible Lightspeed section to log in to Ansible Lightspeed.
  4. Select an option in the initialize section of Ansible Development tools to scaffold files and directories for a collection project or a playbook project.

  5. Select options in the Add section of Ansible development tools to add files for playbooks or roles to your project. Alternatively, you can use the options in the Ansible Lightspeed section to generate playbooks or roles.
  6. Save your work:

    1. Click the main menu icon in the Activity bar and select Terminal New Terminal.
    2. Use git add and git commit commands to stage the changed files and commit your changes to the local repository in the workspace.
    3. Use the git push command to push your updates to your repository in your source control manager.

You can continue your work in a previously created workspace. Workspaces that have been inactive for a set period might be paused to free up resources. The duration of inactivity before timeout is configured in OpenShift Dev Spaces by your administrator. A paused workspace automatically relaunches when you select it from the OpenShift Dev Spaces dashboard.

Ansible lint indicates errors in your playbooks.

Procedure

  1. To display your previously created workspaces, select Workspaces in your OpenShift Dev Spaces dashboard.
  2. Select Open next to the workspace that you want to use.
  3. Select the Explorer icon in the Activity bar to open the file explorer, and open the file you want to edit.
  4. While you are editing, the Ansible extension provides suggestions. Select a suggestion from the dropdown list to include it in your playbook.
  5. To view documentation for a keyword or a module, hover your mouse over it.
  6. Open the terminal in VS Code: click the main menu icon in the Activity bar and select Terminal New Terminal.
  7. Select the Problems tab in the terminal to view issues that ansible-lint has identified.

    In the following example, one error is selected in the Problems tab, and the corresponding line in the playbook is highlighted.

  8. When you have resolved the problems in your playbook, a message is displayed in the Problems tab of the terminal.

You can execute a playbook using the Ansible extension in VS Code.

Procedure

  • To execute a playbook in your Ansible development workspace, right-click on a playbook name in the file explorer and select Run ansible playbook via Run ansible playbook via ansible playbook.
Note

You cannot use execution environments in Ansible development workspaces. Do not use ansible-navigator to execute playbooks.

4.4. Sharing your work

To share automation content with your colleagues, you can work from the same repository.

  1. To contribute to a colleague’s project, request the URL for the Git repository that corresponds to your colleague’s Ansible development workspace.
  2. Launch a workspace using the repository URL that your colleague shared.
  3. Work within a new git branch and contribute to your colleague’s repository by creating a merge or pull request.
Back to top
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. Explore our recent updates.

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.

Theme

© 2025 Red Hat