Visual Studio Code extension for Ansible
- 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. Disable hovering over by setting
ansible.hover
tofalse
. - 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. Then press tab
to move inside snippet parameters.
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 below configurations in settings.json.
config name | description |
---|---|
ansible.hover |
Enable/Disable hover over module name functionality. Default is true. |
ansible.credentialsFile |
Specify ansible credentials file path, used when run playbook in Docker/Local Ansible. Default is $HOME/.vscode/ansible-credentials.yml . |
ansible.termininalInitCommand |
Specify customized terminal init command when run playbook in Docker/Local Ansible. Default is docker run command for Docker, and ansible-playbook for local ansible. |
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
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Please see below documents to learn how to contribute: