Skip to main content
In this lesson you’ll prepare a consistent Ansible development environment so each playbook you open or create in the editor receives instant validation, module suggestions, and linting feedback. We’ll configure Visual Studio Code on a clean RHEL 10 system, install the Red Hat Ansible extension (plus YAML support if needed), add optional development helpers (ansible-lint, yamllint, ansible-core), and verify that the extension detects and validates playbooks. Scenario: your team uses mixed workflows (remote editing, plain editors, local VS Code). The objective is to standardize the developer experience so everyone gets the same in-editor assistance and linting.
A dark-themed infographic titled "Standardizing the Workflow" with three laptop illustrations labeled "Uses simple text editors," "Edits playbooks on remote servers," and "Works locally in VS Code." Dashed lines connect each box to a central gear icon labeled "Standardized Development Workflow."

Overview — what we’ll do

  • Ensure Python tooling (pip3) is present.
  • Download and install Visual Studio Code (RPM for RHEL/Fedora).
  • Install the Red Hat Ansible extension and YAML language support.
  • Install optional Ansible development helpers via pip3 (ansible-core, ansible-lint, yamllint or ansible-devtools).
  • Open your project in VS Code and validate extension features with a sample playbook.
ResourcePurposeExample / Link
Visual Studio CodeEditor with extension marketplacehttps://code.visualstudio.com/
Red Hat Ansible extensionAutocomplete, linting, playbook helpersMarketplace: redhat.ansible
Python/pip3Install Ansible helper toolssudo dnf install -y python3-pip
ansible-core, ansible-lint, yamllintLinting and parsing support for the extensionpip3 install —user ansible-core ansible-lint yamllint

1. Prepare the system: confirm pip3 is available

On a minimal RHEL 10 image pip may not be present. Check with:
student@control:~/project$ pip
bash: pip: command not found
If pip is missing, install the distribution package:
sudo dnf install -y python3-pip
Verify pip3:
pip3 --version
# Example:
# pip 23.3.2 from /usr/lib/python3.12/site-packages/pip (python 3.12)
Tip: use pip3 (not pip) to target the system Python 3 environment on modern RHEL systems.

2. Download and install Visual Studio Code (RPM)

Visit the Visual Studio Code download page and choose the RPM for Red Hat / Fedora (suitable for RHEL 10). You can install the downloaded RPM via the GUI package installer or from the terminal:
sudo dnf install ./code-*.rpm
A web browser screenshot showing the Visual Studio Code documentation page, with a “Thanks for downloading VS Code!” banner at the top and "Getting started" and feature sections below. The left sidebar lists docs topics and a Download button is visible in the toolbar.
Launch VS Code from the desktop menu or terminal:
code

3. Install the Red Hat Ansible extension (and YAML support)

Open the Extensions view (Ctrl+Shift+X), search for “Ansible”, and install the Red Hat Ansible extension (redhat.ansible). If you do not already have YAML language support, install the Red Hat YAML extension (redhat.vscode-yaml) — the Ansible extension relies on robust YAML parsing for many features.
A dark-themed Visual Studio Code window showing the Extensions Marketplace with Ansible-related extensions on the left and a central welcome panel titled "Create an Ansible environment" that illustrates creating an Ansible playbook and project. The right side shows a "Build with agent mode" pane and a small notification about Red Hat extension telemetry.
The Ansible extension delegates linting and parsing to helper tools such as ansible-core, ansible-lint, and yamllint. Install them individually with pip3:
pip3 install --user ansible-core ansible-lint yamllint
Or, where available, install a meta-package like ansible-devtools:
pip3 install --user ansible-devtools
Example (truncated) pip output:
Collecting ansible-core
Collecting ansible-lint
Collecting yamllint
Collecting ruamel.yaml
...
Successfully installed ansible-core-2.20.0 ansible-lint-25.9.2 yamllint-1.37.1 ruamel.yaml-0.18.16
Note: The extension will also work with system-installed ansible or ansible-core; ensure ansible-core exists if you want to run playbooks locally from VS Code.

5. What the Ansible extension provides

After installation, the Red Hat extension exposes features like:
  • Autocompletion for modules and parameters (with FQCN support).
  • Linting annotations (ansible-lint, yamllint integration).
  • Quick actions for running or debugging playbooks.
  • Playbook and inventory detection in the workspace.
A screenshot of Visual Studio Code displaying the Ansible extension page (by Red Hat) with details, installation requirements, and a preview image. The left sidebar shows Ansible development tools and the right panel has a "Build with agent mode" prompt.

6. Open your Ansible project folder

Open the folder that contains ansible.cfg, inventory, and playbooks. VS Code will prompt whether you trust the workspace authors — decide according to your security policy.
When prompted “Do you trust the authors of the files in this folder?”, follow your organization’s security guidance. Opening untrusted workspaces can restrict some extension features until you mark the workspace as trusted.
A Visual Studio Code window displaying the Welcome screen with a central modal asking "Do you trust the authors of the files in this folder?" and buttons to trust or not trust. The Explorer shows a "project" folder (with ansible.cfg, inventory, playbook.yml) and an agent/agent-mode panel on the right.

7. Validate the extension with a sample playbook

Create or open a minimal playbook (playbook.yml) to see autocompletion and linting in action. Example:
---
- name: My Play
  hosts: webservers
  tasks:
    - name: Show message
      ansible.builtin.debug:
        msg: "Hello, world"
As you edit:
  • Autocomplete suggestions appear for modules and parameters.
  • ansible-lint/yamllint (if installed) will surface warnings or rule violations.
  • The extension recommends using fully-qualified collection names (FQCN), e.g., ansible.builtin.debug.
Using fully-qualified module names (for example ansible.builtin.debug) makes playbooks unambiguous about which collection provides a module. Short names (like debug) still work but can trigger linter warnings depending on your ruleset.

8. Run the playbook

Run the playbook from VS Code’s integrated terminal or use quick run actions from the extension. A standard command:
ansible-playbook -i inventory playbook.yml
If you prefer to run within VS Code, use the integrated terminal (View → Terminal) or the extension’s run actions.

Troubleshooting — common issues

  • No hosts matched / host unreachable:
    • Verify inventory group names and host entries.
    • Ensure SSH connectivity and correct credentials.
  • Linter warnings you disagree with:
    • Configure ansible-lint rules via a .ansible-lint or configuration file in your project, or disable specific checks.
  • Extension not recognizing playbooks:
    • Confirm the workspace contains typical Ansible files (ansible.cfg, inventory, playbook.yml) and that workspace trust is enabled if necessary.
If a host (e.g., host1) is marked unreachable:
  • Confirm the host exists in the inventory and is assigned to the correct group (e.g., webservers).
  • Verify network connectivity, SSH keys, and user settings.
With VS Code, the Red Hat Ansible extension, and the optional helper tools installed, you’ll have consistent in-editor completion, linting, and the ability to run playbooks — improving collaboration and code quality across your team.

Watch Video