Page
Access OpenShift Dev Spaces in the Developer Sandbox
Our first step in exploring the seamless integration of Red Hat OpenShift Dev Spaces and Ansible is to access OpenShift Dev Spaces.
To access OpenShift Dev Spaces, visit the Developer Sandbox. Click on the ‘Red Hat Dev Spaces’ card, which will redirect you to the user dashboard for OpenShift Dev Spaces (see Figure 1).
Start a workspace
From the user dashboard, select the Create Workspace tab and input the following URL into the Git Repo URL field: https://github.com/redhat-developer-demos/ansible-devspaces-demo. Then select Create & Open (Figure 2).
During the workspace startup, you will be asked to authorize the GitHub OAuth app configured for each of the Developer Sandbox clusters (Figure 3).
Authorization allows users full GitHub access from the workspaces to execute commands like git push
without any setup. Under the hood, once the permissions are granted, the git-credentials-secret
is created in the user namespace, which stores the token used by OpenShift Dev Spaces (Figure 4).
Note: You can revoke access at any time by selecting User Preferences -> Git Services from the user dashboard or revoking it directly from the GitHub settings.
Once you have started the workspace, you will be able to see the source code of the application you are going to work with (Figure 5).
The workspace contains not only the source code, but also the runtime that lets you instantly start coding and provides the development environment for the following:
- Ansible playbook creation
- Testing with Molecule
- ansible-navigator
- ansible-lint checks
Repeatable and fast development environments are the major benefits of the Red Hat OpenShift Dev Spaces. You can use the workspace you create to immediately start working on your Ansible projects without worrying about manually setting up your local development environment.
With OpenShift Dev Spaces, your development environment–including the commands for running the full Molecule test scenario or each stage one by one–is defined in a declarative way using the devfile.yaml in the root of the repository (Figure 6).
Devfile is a Cloud Native Computing Foundation (CNCF) sandbox project that provides an open standard, which defines containerized development environments. Learn more about Devfile from the official documentation.
OpenShift Dev Spaces supplies a VS Code-like editing experience that many developers find productive. It is highly configurable with an extension library that supports any development workflow. The Ansible VS Code extension is present in the workspace, which allows for instant syntax checking, linting, and autocomplete to accelerate development. Because the workspace also provides Python language support, YAML, and OpenShift Toolkit extensions, you can add additional extensions for GitHub pull request support or any other extension published on the Open VSX Registry (Figure 7).
Congratulations! You have started a workspace. Your second step in your journey through OpenShift Dev Spaces and Ansible is to test a sample Ansible role.