Before you start working with Puppet, make sure that the Puppet Support plugin is enabled. The plugin is bundled with RubyMine and is activated by default. If the plugin is not activated, enable it on the Plugins settings page of the Settings / Preferences Dialog as described in Enabling and Disabling Plugins.
puppet gem should be installed on your Ruby SDK.
Puppet files are marked with .
Puppet support in RubyMine includes:
- Compliance with the Puppet Style Guide.
- Syntax and error highlighting.
- Ability to rename Puppet elements.
- Code completion in
- Configuring code style for Puppet files.
- Structure view:
- Code completion:
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
apachein code completion:
- Navigation to a class definition, symbol, class or a usage is available:
- Future parser.
- Support for the EPP template language.
- RubyMine correctly identifies the
eppfiles, recognizes the native EPP syntax and auto-completes expressions and parameter tags:
Moreover, RubyMine allows you to navigate between a manifest and a template called.
- Rename refactoring is available for the variables and parameters in the
- Finding usages is available for template files (Alt+F7.)
For more information, see the blog post here.
- RubyMine correctly identifies the
Creating a Puppet module
To create a Puppet Module, follow these steps:
- On the main menu, choose Welcome Screen. . You can also click the link on the
- In the New Project dialog, choose the option Puppet Module:
- In the right-hand pane, specify the project location, select the desired Ruby SDK, enter the author username and module name.
If Puppet gem is not installed, then instead of the Puppet gem version you'll see the suggestion to install the gem:
For the macOS and *NIX users: When choosing Ruby SDK, you can select an RVM gemset from the existing ones, or create a new one: Refer to the page Configuring Gemsets for details.
- When ready, click Create.
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.
There is an action in the Project tool window that enables installing dependencies into a Puppet module:
Puppet modules recognize dependencies from 3 different sources:
- If the file
.fixtures.ymlexists in a Puppet module, then the dependencies are installed into the directory
spec/fixtures/modules, no other sources being checked.
- If a
Puppetfileexists in a Puppet module, then the dependencies are installed using
.dependenciesdirectory. If a
librarian-puppetignores dependencies specified in
- If a
metadata.jsonfile exists in a Puppet module, then the dependencies are installed using
Here’s how it works...
To work with a Puppet project, follow these general steps:
- Open or create a Puppet module.
- If installing dependencies from the files
metadata.json, make sure that the gem librarian-puppet is installed. If the gem is not yet installed, RubyMine notifies you about the missing gem and suggests to install it:
(If the dependencies are installed from
.fixtures.ymlfile, this gem is not required, and no notification will be shown.)
RubyMine 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 RubyMine 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.
- Having placed the dependencies in the file
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
metadata.json, located in the project root. The folder
.dependencies(in case of creating dependencies from
spec/fixtures/modules/(in case of creating dependencies from
.fixtures.yml) is created under the project root, if it didn't exist before.
If you want to add more dependencies, invoke this command again.