IntelliJ IDEA 2017.2 Help

Puppet

In this section:

Prerequisites

Before you start working with Puppet, make sure that the Puppet Support plugin is enabled. The plugin is bundled with IntelliJ IDEA and is activated by default. If the plugin is not activated, enable it on the Plugins page of the Settings / Preferences Dialog as described in Enabling and Disabling Plugins.

Also, puppet gem should be installed on your Ruby SDK.

Puppet support

Puppet files are marked with /help/img/idea/2017.2/icon_puppet.png.

Puppet support in IntelliJ IDEA includes:

  • Compliance with the Puppet Style Guide.
  • Syntax and error highlighting.
  • Ability to rename Puppet elements.
  • Code completion in *.pp files.
  • Configuring code style for Puppet files.
  • Structure view:
    /help/img/idea/2017.2/puppet_structure_view.png
  • Code completion:
    /help/img/idea/2017.2/puppet_completing_keywords.png

    Moreover, with the dependencies installed, navigation and completion for each module work in strict accordance with the dependencies. For example, if you are editing a module depending on puppetlabs-apache, then you see apache in code completion:

    /help/img/idea/2017.2/puppet_completion.png
  • Navigation to a class definition, symbol, class or a usage is available:
    /help/img/idea/2017.2/rm_puppet_goto_symbol.png
  • Future parser.

Creating a Puppet module

To create a Puppet Module, follow these steps

  1. On the main menu, choose File | New | Project.... You can also click the Create New Project link on the Welcome Screen.
  2. On the first page of the wizard, specify the project SDK, author's username and module name.
    /help/img/idea/2017.2/ij_create_puppet_module.png

    If Puppet gem is not installed, then instead of the Puppet gem version you'll see the suggestion to install the gem:

    /help/img/idea/2017.2/puppet_install.png

    For the macOS and *NIX users: When choosing project SDK, you can select an RVM gemset from the existing ones, or create a new one:

    /help/img/idea/2017.2/puppet-gemset.png
    Refer to the page Configuring Gemsets for details.

    Click Next

  3. On the second page of the wizard, specify the project name and location:
    /help/img/idea/2017.2/ij_create_puppet_module_second_page.png
  4. When ready, click Finish.

The project is created in the specified location. So doing, the created project features the structure of a Puppet module. Refer the Puppet documentation for details.

/help/img/idea/2017.2/puppet_project_created.png

Installing dependencies

There is an action in the Project tool window that enables installing dependencies into a Puppet module:

/help/img/idea/2017.2/puppet_install_dependencies.png

Puppet modules recognize dependencies from 3 different sources:

  1. If the file .fixtures.yml exists in a Puppet module, then the dependencies are installed into the directory spec/fixtures/modules, no other sources being checked.
  2. If a Puppetfile exists in a Puppet module, then the dependencies are installed using librarian-puppet into .dependencies directory. If a Puppetfile exists, librarian-puppet ignores dependencies specified in metadata.json.
  3. If a metadata.json file exists in a Puppet module, then the dependencies are installed using librarian-puppet into .dependencies directory.

Typical workflow

Here’s how it works...

To work with a Puppet project, follow these general steps:

  1. Open or create a Puppet module.
  2. If installing dependencies from the files Puppetfile or metadata.json, make sure that the gem librarian-puppet is installed. If the gem is not yet installed, IntelliJ IDEA notifies you about the missing gem and suggests to install it:
    /help/img/idea/2017.2/puppet_install_gem.png

    (If the dependencies are installed from .fixtures.yml file, this gem is not required, and no notification will be shown.)

    IntelliJ IDEA can find all modules/environments in a project automatically, based on dependencies files, and updates the project structure accordingly, if anything has changed. Even if IntelliJ IDEA fails to update your project structure after installing additional modules into the project using the terminal, you can manually rescan the directory for modules or environments by using Scan for modules and environments action on the context menu.

  3. Having placed the dependencies in the file .fixtures.yml, Puppetfile or metadata.json, right-click the Project Tool Window, and then choose Install dependencies for module <module name> on the context menu.

    So doing, the dependencies are taken from the files .fixtures.yml, Puppetfile or metadata.json, located in the project root. The folder .dependencies (in case of creating dependencies from Puppetfile or metadata.json) or spec/fixtures/modules/ (in case of creating dependencies from .fixtures.yml) is created under the project root, if it didn't exist before.

    /help/img/idea/2017.2/puppet_install_dependencies1.png

    If you want to add more dependencies, invoke this command again.

Last modified: 11 October 2017

See Also