Skip to content

Dev Containers

Ansible development works best when the editor, terminal, linters, and Python environment share one container image. This guide covers three related jobs:

  1. Using a Dev Container for day-to-day Ansible work
  2. Adding a .devcontainer/ config to a project (via ansible-creator)
  3. Layering ansible-dev-tools onto an Execution Environment (EE) so that EE can be the Dev Container image

The Ansible extension follows ADR-003: EE-based development uses Dev Containers, not docker exec / podman exec routing.

  • Dev Containers extension (ms-vscode-remote.remote-containers)
  • Podman or Docker
  • ansible-creator (included with ansible-dev-tools)
  1. Open your project folder in VS Code or a compatible editor.
  2. Ensure the project has a .devcontainer/ directory (see Add a Dev Container file below).
  3. Press Ctrl+Shift+P / Cmd+Shift+P → Dev Containers: Reopen in Container.
  4. The editor reconnects inside the container. The Ansible extension activates against the container’s Python environment and collections.

Creator scaffolds Docker and Podman variants under .devcontainer/. Pick the variant that matches your engine, or use the root devcontainer.json when present.

Apps started from the Dock/Start menu often miss shell PATH. Prefer an absolute dev.containers.dockerPath:

{
"dev.containers.dockerPath": "/opt/podman/bin/podman"
}

On Linux the binary is often /usr/bin/podman. Confirm with command -v podman.

Use ansible-creator as the source of truth for scaffolding (same templates as ansible-creator’s common devcontainer resources).

Terminal window
ansible-creator add resource devcontainer /path/to/project --image <image>

--image accepts any container image reference (for example an EE tag, or ghcr.io/ansible/community-ansible-dev-tools:latest). Defaults to auto when omitted.

In the Ansible sidebar, open Creator → Add → devcontainer, fill in path and image, then run.

ac_add_res_devc({
"path": "/path/to/project",
"image": "ghcr.io/ansible/community-ansible-dev-tools:latest"
})

From an Execution Environment in the sidebar

Section titled “From an Execution Environment in the sidebar”

Right-click an image under Execution Environments → Add Dev Container. That opens the Creator form with --image set to the selected EE.

Generated layouts typically include Docker and Podman devcontainer.json files with containers-in-containers (C-in-C) friendly runArgs (fuse device, SYS_ADMIN, seccomp/apparmor settings). Those match the patterns used by ansible-dev-tools.

Most production EEs ship Ansible and collections but not the full developer toolkit (ansible-lint, ansible-creator, molecule, and so on). Layer ansible-dev-tools before using the EE as a Dev Container image.

Option A — Bake into execution-environment.yml

Section titled “Option A — Bake into execution-environment.yml”
---
version: 3
images:
base_image:
name: quay.io/ansible/ansible-runner:latest
dependencies:
python_interpreter:
package_system: python3.11
python:
- ansible-dev-tools
galaxy:
collections:
- name: ansible.netcommon
Terminal window
ansible-builder build -f execution-environment.yml -t my-ee-with-devtools:latest

Then scaffold with --image my-ee-with-devtools:latest.

Option B — Outer Containerfile on an existing EE

Section titled “Option B — Outer Containerfile on an existing EE”

When you cannot rebuild the EE definition, write an outer Containerfile that layers tools on top:

FROM registry.redhat.io/ansible-automation-platform/ee-supported-rhel9:latest
USER root
RUN pip3 install --no-cache-dir ansible-dev-tools
USER 1000

Build it:

Terminal window
podman build -t my-ee-with-devtools:latest -f Containerfile .

Pass the tagged image to creator:

Terminal window
ansible-creator add resource devcontainer . --image my-ee-with-devtools:latest

Alternatively keep the Containerfile under .devcontainer/ and point devcontainer.json at it with "build": { "dockerfile": "Containerfile" } instead of "image".

Use the Execution Environments tree (or MCP list_execution_environments / get_ee_details) to see whether ansible-dev-tools is already present.

Image Role
ghcr.io/ansible/community-ansible-dev-tools:latest Ready-made community ADT image
registry.redhat.io/ansible-automation-platform/ee-supported-rhel9:latest Supported AAP EE (layer ADT if needed)
registry.redhat.io/ansible-automation-platform/ee-minimal-rhel9:latest Minimal EE (layer ADT for interactive work)
Your custom EE Prefer baking ADT into the EE definition

Set absolute dev.containers.dockerPath as above, reload the window, retry Reopen in Container.

Prefer SSH agent forwarding on the host (ssh-add) — Dev Containers forwards the agent. Avoid bind-mounting ~/.ssh.

The image likely lacks ansible-dev-tools. Use Option A or B, or install temporarily with pip install ansible-dev-tools inside the running container.