Setting up VS Code for Bolt

Bolt configuration and inventory files, as well as content such as plans and task metadata, conform to particular specifications. Making your development environment aware of these specifications gives you real-time validation and data type checking as you write, speeding up the development cycle and reducing errors.

Validating configuration and inventory files with JSON schemas

You can validate Bolt's configuration and inventory files using JSON schemas provided through the Puppet Forge. Configuring Visual Studio Code (VS Code) to use Bolt's JSON schemas enables VS Code's live IntelliSense feature, which gives you functionality like code completion and parameter info for available fields in the files.

Bolt offers the following JSON schemas:

Bolt file JSON schema
bolt-defaults.yaml https://forgeapi.puppet.com/schemas/bolt-defaults.json
bolt-project.yaml https://forgeapi.puppet.com/schemas/bolt-project.json
inventory.yaml https://forgeapi.puppet.com/schemas/bolt-inventory.json
YAML plans https://forgeapi.puppet.com/schemas/bolt-yaml-plan.json

Enabling schemas

To start using the JSON schemas with VS Code, follow these steps:

  1. Install the YAML extension.

  2. Open the user or workspace settings file and add the following JSON:

    {
      "yaml.schemas": {
        "https://forgeapi.puppet.com/schemas/bolt-defaults.json": [
          "bolt-defaults.yaml"
        ],
        "https://forgeapi.puppet.com/schemas/bolt-project.json": [
          "bolt-project.yaml"
        ],
        "https://forgeapi.puppet.com/schemas/bolt-inventory.json": [
          "inventory.yaml"
        ],
        "https://forgeapi.puppet.com/schemas/bolt-yaml-plan.json": [
          "plans/**/*.yaml"
        ]
      }
    }

📖 Related information

Developing Bolt content with the Puppet VS Code Extension

Puppet offers a VS Code Extension that you can use when developing content for your Bolt project. The Puppet VS Code Extension includes many powerful features, including validation for task metadata files, live Intellisense for Puppet plans, validating Puppetfiles, and more.

To install the Puppet VS Code Extension, see How to start using the Puppet VS Code Extension.

📖 Related information