Get started with the Ansible Visual Studio Code extension

Take a guided walkthrough of the Ansible extension for Visual Studio Code (VS Code).

Now that we have seen key features of Ansible VS Code extension, let's look at how to execute Ansible playbooks from the extension. 

In this lesson, you will:

  • Learn how to execute Ansible Playbooks from VS Code.
  • Learn how to integrate version control in VS Code.

Execute Ansible playbooks from VS Code

The VS Code extension provides an option to run an Ansible playbook from within the extension either using ansible-navigator run or ansible-playbook command (Figure 1).

Figure shows how to run Ansible playbook in the VS Code extension.
Figure 1: Running a playbook in the VS Code extension.

You can include an ansible-navigator.yml or an ansible.cfg file in your project root directory. The configured values will be automatically picked up in the runs using ansible-navigator or ansible-playbook respectively. The playbook run will open a terminal window in VS Code where you can see all the run details as well as any debugging information.

Integrate version control

VS Code provides Git support out of the box. While this is not a feature of Ansible VS Code extension, it is important to understand how to integrate and use the features provided by VS Code.

Please refer to these instructions for a deep dive on integrating version control within VS Code.

Additional resources and where to go next

Have feedback on this learning path? Share it with us.

Previous resource
Connect the extension to Ansible Lightspeed with IBM watsonx Code Assistant