Write your first automation task using the VS Code extension
Learn how to write, inspect, debug, and run Ansible playbooks directly within VS Code using Ansible development tools.
Set up the Ansible configuration file
When you scaffolded your playbook project, an Ansible configuration file, ansible.cfg, was added to the root directory of your project.
Procedure
If you have configured a default Ansible configuration file in
/etc/ansible/ansible.cfg, copy any settings that you want to reuse in your project from your default Ansible configuration file to the ansible.cfg file in your project’s root directory.
To learn more about the Ansible configuration file, see Reviewing your Ansible configuration with automation content navigator.
Write your first playbook
Create your first Ansible playbook within VS Code using the Ansible extension. The tools available help ensure that your syntax is correct and ready to run.
Before you begin
- You have installed and opened the Ansible VS Code extension.
- You have opened a terminal in VS Code.
- You have installed
ansible-devtools.
Procedure
Inspect your playbook
The Ansible VS Code extension provides inline help, syntax highlighting, and assists you with indentation in .yml files.
Procedure
Debug your playbook
Learn how to use VS Code to identify and understand error messages in playbooks.


