Chapter 3. Creating and launching an Ansible development workspace
An administrator installs Red Hat OpenShift Dev Spaces. After installation, developers can use the provided OpenShift Dev Spaces dashboard to create Ansible development workspaces that include a web-based version of VS Code.
3.1. Authentication Copy linkLink copied to clipboard!
Ansible dev spaces must be able to authenticate with your Git source control manager (SCM).
- If your organization has integrated Git source control OAuth authentication with Ansible dev spaces, you do not need to configure authentication between OpenShift Dev Spaces and your Git SCM.
- If your organization has not set up OAuth authentication, you must generate personal access tokens for authentication between OpenShift Dev Spaces and your Git SCM.
3.1.1. Configuring Git personal access token authentication Copy linkLink copied to clipboard!
You must create a personal access token (PAT) in your Git source control manager (SCM), and add it to OpenShift Dev Spaces to enable access to your repositories from your Ansible development workspace.
Procedure
Create a personal access token in your Git SCM and save it.
- See Managing your personal access tokens in the GitHub documentation.
- See Personal access tokens in the Gitlab documentation.
- In a browser, navigate to the OpenShift Dev Spaces dashboard provided by your administrator, and log in.
- Expand the dropdown menu under your login name and select User Preferences.
- Select Personal Access Tokens.
- Click +Add Token.
Complete the Add Personal Access Token form:
- Token Name: Enter a name for your token
- Token: Enter your personal access token for your Git repository.
- Click Add to save the personal access token.
3.2. Creating a Git repository for an Ansible development workspace Copy linkLink copied to clipboard!
To launch an Ansible development workspace, you must provide a link to a Git repository that defines the development environment. The repository also stores the automation content you create in Ansible dev spaces.
- If your administrator provides an example repository for your team, fork the repository to create your own copy.
If you do not have access to an example repository, you must create your own repository.
-
Create a directory for your new repository and use
git initto initialize it as a Git repository. -
Add a
devfile.yamlfile to the repository to define the Ansible dev spaces image that you want to use for your Ansible development workspace. See Creating a devfile for Ansible development workspaces. -
Add a
.code-workspacefile to the repository to specify the VS Code extensions for your Ansible development workspace. See Creating a.code-workspacefile for Ansible development workspaces.
-
Create a directory for your new repository and use
3.3. Creating a devfile for an Ansible development workspace Copy linkLink copied to clipboard!
To ensure your Ansible development workspace launches with the correct Ansible dev spaces image, you must add a devfile to your git repository. A devfile is a YAML file that defines the development environment for a project in Red Hat OpenShift Dev Spaces.
Procedure
-
In your Git repository for your Ansible development workspace, create a new file named
devfile.yaml. Copy and paste the following sample code into the
devfile.yamlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Modify the image value to the name of your specific Ansible image.
-
Add the
devfile.yamlfile to your Git repository and push the changes to your source control manager (SCM).
3.4. Creating a .code-workspace file for an Ansible development workspace Copy linkLink copied to clipboard!
To configure VS Code extensions that are included in your Ansible development workspace, you must add a .code-workspace JSON file to your git repository.
Procedure
-
In your Git repository for your Ansible development workspace, create a new file named
.code-workspace. Copy and paste the following sample code into the
.code-workspacefile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
If you want to add extra extensions to your Ansible development workspace, add them in the
extensions.recommendationssection of the file. -
Add the
.code-workspacefile to your Git repository and push the changes to your source control manager (SCM).
3.5. Launching an Ansible dev spaces workspace Copy linkLink copied to clipboard!
Prerequisites
- Your administrator has provided a URL for a OpenShift Dev Spaces dashboard.
-
You have prepared a git repository that contains the
devfile.yamland.code-workspacefiles that define the Ansible development workspace configuration.
Procedure
- In a browser, navigate to the OpenShift Dev Spaces dashboard and log in.
- Select Create Workspace in the navigation pane.
-
In the Import from Git field of the Create Workspace form, enter the URL for the Git repository that contains your
devfile.yamland.code-workspacefiles. - Click Create & Open.
OpenShift Dev Spaces displays the progress for the provisioning process of your Ansible development workspace.
After the Ansible development workspace launches, a VS Code environment opens in your browser.
To open a terminal for executing commands and viewing
ansible-lintsuggestions in VS Code, click the main menu icon in the Activity bar and select. For more information about working in a VS Code terminal, see Getting started with the terminal in the VS Code documentation.