Git Product home page Git Product logo

vscode-ansible's Introduction

Travis CI AppVeyor Marketplace Version

Visual Studio Code extension for Ansible

Table of Content

Overview

This extension helps to use Ansible efficiently in VSCode.

Features

  • 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.

Prerequisites

platform prerequisite
Run Playbook in Cloud Shell/Remotely via ssh nodejs >= 6.0
Run Playbook in Docker Docker
Run Playbook in Local Ansible Ansible

Usage

Auto completion

Code snippets

Press Ctrl + Space in playbook yml file, you'll see Ansible modules code snippets.
auto completion and code snippets

Run Ansible playbook

4 methods are supported to run Ansible playbook:

  • Docker.

  • Local Ansible installation.

  • Cloud Shell.

  • Remotely via ssh.

    run playbook

Run Playbook in Docker

  1. Make sure Docker is installed and running. For non-Windows platform, please configure Docker run without sudo.

  2. 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.
    docker share driver

  3. 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 item ansible.credentialsFile. Credential file template is at here.

  4. Press F1, type: ansible, choose Run Ansible Playbook in Docker. Or right click playbook yaml file, choose Run Ansible Playbook in Docker.

  5. 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.

Run Playbook in Local Ansible

  1. Make sure Ansible is installed.
  2. 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 item ansible.credentialsFile. Credential file template is at here.
  3. Press F1, type: ansible, choose Run Ansible Playbook in Local Ansible. Or right click playbook yaml file, choose Run Ansible Playbook in Local Ansible.

Run Playbook in Cloud Shell

  1. 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.
  2. Install Azure Account VSCode extension, which is used for Azure login.
  3. Press F1, type: Azure: Sign In, do Azure login.
  4. Press F1, type: ansible, choose Run Ansible Playbook in Cloud Shell. Or right click playbook yaml file, choose Run Ansible Playbook in Cloud Shell.
  5. Input playbook file full path, or use default one.
  6. Confirm awareness on Azure usage fee. Please refer to this document to learn more about Azure Cloud Shell pricing.

Run Playbook Remotely via ssh

  1. 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"
         }
    ]
    

Configuration

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.

Feedback and Questions

You can submit bug or feature suggestion via issues.

License

MIT license.

Telemetry

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

vscode-ansible's People

Contributors

yungezz avatar yuwzho avatar zhijunzhao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.