이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 4. Scaffolding an Ansible project with the AI assistant
Use the Ansible VS Code extension’s embedded MCP server to generate a new project structure, and to create and scaffold new content such as playbooks or collections. With the AI assistant, you can ensure the project aligns with best practices and organizational standards without manually creating boilerplate code.
4.1. Prerequisites 링크 복사링크가 클립보드에 복사되었습니다!
- The Ansible VS Code extension is installed, running, and enabled in Agent Mode.
- The Ansible MCP server is enabled in the Ansible VS Code extension.
- Ansible development tools is installed.
4.2. Generate and view best practices for creating Ansible content 링크 복사링크가 클립보드에 복사되었습니다!
Before starting to create content, use the MCP server-enabled Ansible VS Code extension to generate and view Ansible best practices and coding guidelines.
Procedure
- Open the Copilot chat window by clicking the GitHub Copilot icon in the VS Code sidebar.
Enter a natural language prompt requesting Ansible best practices. For example:
Show me Ansible best practices and coding guidelines so that I can write high-quality playbooks.
This triggers the
ansible_content_best_practicestool, which displays the guidelines for you to read within the editor.
Enter a prompt requesting The Zen of Ansible. For example:
Show me the Zen of Ansible
This triggers the
zen_of_ansibletool, which will list Zen of Ansible principles for you to read within the editor.
4.3. Create the project structure with the AI assistant 링크 복사링크가 클립보드에 복사되었습니다!
Enter a prompt in natural language to trigger the project creation tool. When prompted, ansible-creator works in the background to generate the directory structure.
Procedure
In the Copilot chat window, enter a prompt specifying the project name and type. For example:
Create a new Ansible playbook project called `webserver-deployment.`
This triggers the
create_ansible_projectstool. The extension then executesansible-creator init playbookto generate the content.
Verification
After the assistant confirms that the task is complete, verify that the project structure is consistent with the standard layout.
- Navigate to the VS Code Explorer view.
-
Locate the new directory (per the example above,
webserver-deployment/). Confirm the presence of standard artifacts such as:
- Initial playbook files.
-
Recommended configuration files (such as
ansible.cfg,inventory).
4.4. Scaffold content with the AI assistant 링크 복사링크가 클립보드에 복사되었습니다!
If you need to generate specific content within the project using specific templates (such as a playbook or execution environment), you can continue the conversation.
Procedure
In the GitHub Copilot chat window, enter a natural language prompt requesting help with creating the type of content you need. For example:
- For a playbook project, enter the prompt: Following best practices, help me create a playbook called 'webserver'…"
- For an execution environment, enter the prompt: Create an execution environment definition file using Fedora minimal as the base"