此内容没有您所选择的语言版本。
Chapter 1. Set up your development environment with the MCP server-enabled Ansible VS Code extension
Use the MCP server-enabled Ansible AI assistant within the Ansible VS Code extension to:
- Query your environment to understand which tools are already installed.
-
Install
ansible-dev-tools. - Set up and configure your development environment.
1.1. Prerequisites 复制链接链接已复制到粘贴板!
- The latest version of Python is installed.
1.2. Run environment diagnostics 复制链接链接已复制到粘贴板!
Use the AI assistant to assess your local environment to understand what tools, versions, and collections are currently installed.
Procedure
- Open GitHub Copilot chat.
Enter a prompt in natural language asking the AI assistant what is installed in your environment. For example:
- Check my Ansible environment and tell me what’s installed.
What collections are installed?
The assistant then triggers the
ade_environment_infotool.
Review the output, which typically includes:
- Workspace path and Python version
- Virtual environment status
-
Ansible Automation Platform and
ansible_lintversions - A list of installed collections
- The installation status of Ansible development tools (ADT).
If you do not have Ansible development tools (ADT) installed, you can instruct the AI assistant to install them.
Procedure
- Open GitHub Copilot chat.
Enter the prompt: Make sure I have
ansible-dev-toolsinstalled.The system then checks if Ansible development tools is installed. If so, the assistant will report that
ansible-dev-toolsis installed. If Ansible development tools is not installed, the AI assistant chooses a package manager (piporpipx) and installs ADT automatically.
Verification
When installation is complete, the AI assistant will return a message in the Copilot chat window confirming that ADT has been installed successfully. You can also prompt the AI assistant to check my Ansible environment again. If the installation was successful, the AI assistant will verify that ADT is installed in your environment.
After installing Ansible development tools, you can use the MCP server-enabled AI assistant in the Ansible VS Code extension to configure your workspace, including:
- Setting up a virtual environment.
- Installing specific Python versions.
- Adding Ansible collections.
Procedure
- Open GitHub Copilot chat.
In the chat window, enter a natural language prompt instructing the AI assistant to set up the configuration you want. For example:
Set up a complete Ansible development environment with Python 3.11, and install the collections amazon.aws and ansible.posix.
The assistant triggers the
ade_setup_environmenttool, and the system automatically performs the following configuration steps:-
Create a virtual environment: The assistant creates a virtual environment (
venv/) in your workspace. -
Install core tools: The assistant installs
ansible-coreandansible-lintin the new virtual environment. -
Install collections: The assistant installs the requested collections (
amazon.aws,ansible.posix) and their dependencies. -
Check for conflicts: The assistant checks for conflicting packages and verifies
ansible-lintstatus.
-
Create a virtual environment: The assistant creates a virtual environment (
Review the output in the Copilot chat. When setup is complete, the assistant confirms that the environment is set up, and gives instructions on activating the environment. For example:
-
To activate, run
source <path>/venv/bin/activate -
To deactivate, run
deactivate.
-
To activate, run
Verification
Verify that configuration was successful by asking the AI assistant to check the environment status again. For example:
Check my environment again to confirm that everything is set up correctly.
The ade_environment_info tool runs and confirms the Python version, virtual environment path, and installed collections in its output.