This extension helps to use Ansible efficiently in VSCode.
- Auto completion. Auto completion Ansible directives, modules and plugins from Ansible doc, Auto completion for variables.
- Code snippets. Press
Ctrl + Space
, Ansible playbook code snippets will show up. - Syntax highlighting.
- Code navigation by Symbols, press
Ctrl + Shift + O
. - Hover over module names, to show module documentation.
- Run playbook from Docker.
- Run playbook from local Ansible installation.
- Run playbook from Cloud Shell.
- Run playbook remotely via ssh.
platform | prerequisite |
---|---|
Run Playbook in Cloud Shell/Remotely via ssh | nodejs >= 6.0 |
Run Playbook in Docker | Docker |
Run Playbook in Local Ansible | Ansible |
Press Ctrl + Space
in playbook yml file, you'll see Ansible modules code snippets.
4 methods are supported to run Ansible playbook:
-
Make sure Docker is installed and running. For non-Windows platform, please configure Docker run without sudo.
-
For Windows user, please share your Windows driver where vscode workspace sits on with docker. This is because the extension will map your workspace containing playbook with docker.
-
This step is optinal. If you want to run cloud provider specific Ansible modules, you need set cloud credentials in credential yaml file, default path is
$HOME/.vscode/ansible-credentials.yml
, or change credential file path by settings itemansible.credentialsFile
. Credential file template is at here. -
Press
F1
, type:ansible
, chooseRun Ansible Playbook in Docker
. Or right click playbook yaml file, chooseRun Ansible Playbook in Docker
. -
Input playbook file full path, or use default one.
NOTE
- Docker on Windows is not as stable as on other platforms, please try to restart Docker in case of any issue.
- Downloading Docker image first time usage may be time consuming in case of slow network connection.
- Make sure Ansible is installed.
- This step is optinal. If you want to run cloud provider specific Ansible modules, please setup cloud credentials by following Ansible instruction. Or you can set cloud credentials in credential yaml file, default path is
$HOME/.vscode/ansible-credentials.yml
, or change credential file path by settings itemansible.credentialsFile
. Credential file template is at here. - Press
F1
, type:ansible
, chooseRun Ansible Playbook in Local Ansible
. Or right click playbook yaml file, chooseRun Ansible Playbook in Local Ansible
.
- Important Please setup Cloud Shell for first time usage in Azure Portal by following this instruction. After setup, input cmd
az account show
to learn your current subscription setting. - Install Azure Account VSCode extension, which is used for Azure login.
- Press
F1
, type:Azure: Sign In
, do Azure login. - Press
F1
, type:ansible
, chooseRun Ansible Playbook in Cloud Shell
. Or right click playbook yaml file, chooseRun Ansible Playbook in Cloud Shell
. - Input playbook file full path, or use default one.
- Confirm awareness on Azure usage fee. Please refer to this document to learn more about Azure Cloud Shell pricing.
- Configure your remote server in
$HOME/.ssh/servers.json
like below. Or follow wizard to fill in server information.[ { "host": "your host", "port": 22, "user": "your user name", "password": "your ssh password", "key": "your private key" } ]
This extension provides 2 configurations in settings.json.
ansible.credentialsFile
This configuration is used to specify ansible credentials file path. Default is$HOME/.vscode/ansible-credentials.yml
.ansible.termininalInitCommand
This configuration is used to specify customized terminal init command. Default is docker run commands for docker, and 'ansible-playbook' for local setup.
You can submit bug or feature suggestion via issues.
This extension collects telemetry data to help improve our products. Please read Microsoft privacy statement to learn more. If you opt out to send telemetry data to Microsoft, please set below configuration in settings.json:
telemetry.enableTelemetry = false