GithubHelp home page GithubHelp logo

classicvalues / vscode-ansible Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ansible/vscode-ansible

1.0 1.0 0.0 4.35 MB

vscode/vscodium extension for providing Ansible auto-completion and integrating quality assurance tools like ansible-lint, ansible syntax check, yamllint, molecule and ansible-test.

Home Page: https://marketplace.visualstudio.com/items?itemName=redhat.ansible

License: MIT License

JavaScript 3.17% TypeScript 78.93% Python 16.75% Shell 1.15%

vscode-ansible's Introduction

Ansible VS Code Extension by Red Hat

This extension adds language support for Ansible to Visual Studio Code and OpenVSX compatible editors by leveraging ansible-language-server.

Activating Red Hat Ansible extension

It is recommended to open a folder containing Ansible files with a VS Code workspace.

Linter support

Note:

  • For Ansible files open in an editor window ensure the language mode is set to Ansible (bottom right of VS Code window).
  • The runtime status of extension should be in activate state. It can be verified in the Extension window Runtime Status tab for Ansible extension.

Features

Syntax highlighting

Syntax highlighting

Ansible keywords, module names and module options, as well as standard YAML elements are recognized and highlighted distinctly. Jinja expressions are supported too, also those in Ansible conditionals (when, failed_when, changed_when, check_mode), which are not placed in double curly braces.

The screenshots and animations presented in this README have been taken using the One Dark Pro theme. The default VS Code theme will not show the syntax elements as distinctly, unless customized. Virtually any theme other than default will do better.

Validation

YAML validation

While you type, the syntax of your Ansible scripts is verified and any feedback is provided instantaneously.

Integration with ansible-lint

Linter support

On opening and saving a document, ansible-lint is executed in the background and any findings are presented as errors. You might find it useful that rules/tags added to warn_list (see Ansible Lint Documentation) are shown as warnings instead.

Smart autocompletion

Autocompletion

The extension tries to detect whether the cursor is on a play, block or task etc. and provides suggestions accordingly. There are also a few other rules that improve user experience:

  • the name property is always suggested first
  • on module options, the required properties are shown first, and aliases are shown last, otherwise ordering from the documentation is preserved
  • FQCNs (fully qualified collection names) are inserted only when necessary; collections configured with the collections keyword are honored. This behavior can be disabled in extension settings.

Auto-closing Jinja expressions

Easier Jinja expression typing

When writing a Jinja expression, you only need to type "{{, and it will be mirrored behind the cursor (including the space). You can also select the whole expression and press space to put spaces on both sides of the expression.

Documentation reference

Documentation on hover

Documentation is available on hover for Ansible keywords, modules and module options. The extension works on the same principle as ansible-doc, providing the documentation straight from the Python implementation of the modules.

Jump to module code

Go to code on Ctrl+click

You may also open the implementation of any module using the standard Go to Definition operation, for instance, by clicking on the module name while holding ctrl/cmd.

Requirements

For Windows users, this extension works perfectly well with extensions such as Remote - WSL and Remote - Containers.

If you have any other extension providing language support for Ansible, you might need to uninstall it first.

Configuration

This extension supports multi-root workspaces, and as such, can be configured on any level (User, Remote, Workspace and/or Folder).

  • ansible.ansible.path: Path to the ansible executable.
  • ansible.ansible.useFullyQualifiedCollectionNames: Toggles use of fully qualified collection names (FQCN) when inserting a module name. Disabling it will only use FQCNs when necessary, that is when the collection isn't configured for the task.
  • ansible.ansibleLint.arguments: Optional command line arguments to be appended to ansible-lint invocation. See ansible-lint documentation.
  • ansible.ansibleLint.enabled: Enables/disables use of ansible-lint.
  • ansible.ansibleLint.path: Path to the ansible-lint executable.
  • ansible.ansibleNavigator.path: Path to the ansible-navigator executable.
  • ansible.executionEnvironment.containerEngine: The container engine to be used while running with execution environment. Valid values are auto, podman and docker. For auto it will look for podman then docker.
  • ansible.executionEnvironment.enabled: Enable or disable the use of an execution environment.
  • ansible.executionEnvironment.image: Specify the name of the execution environment image.
  • ansible.executionEnvironment.pullPolicy: Specify the image pull policy. Valid values are always, missing, never and tag. Setting always will always pull the image when extension is activated or reloaded. Setting missing will pull if not locally available. Setting never will never pull the image and setting tag will always pull if the image tag is 'latest', otherwise pull if not locally available.
  • ansible.python.interpreterPath: Path to the python/python3 executable. This setting may be used to make the extension work with ansible and ansible-lint installations in a Python virtual environment.
  • ansible.python.activationScript: Path to a custom activate script, which will be used instead of the setting above to run in a Python virtual environment.
  • ansibleServer.trace.server: Traces the communication between VSCode and the ansible language server.

Known limitations

  • The shorthand syntax for module options (key=value pairs) is not supported.
  • Nested module options are not supported yet.
  • Only Jinja expressions inside Ansible YAML files are supported. In order to have syntax highlighting of Jinja template files, you'll need to install other extension.
  • Jinja blocks (inside Ansible YAML files) are not supported yet.

Credit

Based on the good work done by Tomasz Maciążek

vscode-ansible's People

Contributors

dependabot[bot] avatar fgierlinger avatar florianlaunay avatar floschwalm avatar ganeshrn avatar imgbot[bot] avatar jeinwag avatar jpinkney avatar odockal avatar pre-commit-ci[bot] avatar priyamsahoo avatar ssbarnea avatar stopendy avatar tomaciazek avatar webknjaz avatar yaegassy avatar

Stargazers

 avatar

Watchers

 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.