Declare Forge modules in the Puppetfile

When you declare a Forge module in your Puppetfile, you can specify a particular version to track and whether you want code management to automatically update the module.

The Puppetfiledoes not automatically resolve dependencies for Forge modules. When you declare a module in your Puppetfile, you must also declare any required dependent modules.

Forge module symlinks are not supported. When you install modules with r10k or Code Manager, by declaring them in your Puppetfile, symlinks are not installed.

If you have Puppetfiles you used before you started using code management, these files might contain a forge setting that provides legacy compatibility with librarian-puppet. However, this setting is non-operational for Code Manager and r10k. If you need to configure how Forge modules are downloaded, you must specify forge_settings in Hiera. For instructions, refer to Configuring Forge settings for Code Manager or Configuring Forge settings for r10k.

  1. In your Puppetfile, use the mod directive to specify Forge modules you want to install. Specify the module's full name as a string. For example, this declaration is for the apache module:
    mod 'puppetlabs/apache'
    This basic declaration installs the current version of the module that is available during the next code deployment, but it doesn't update the module on future runs. If you want to keep the module updated automatically, you need to specify :latest, as described in the next step.
  2. Optional: Specify whether you want to maintain a specific version of the module or if you want code management to automatically update the module when a new version is available.
    • To continuously keep the module current with the newest version, specify :latest after the module name. For example:
      mod 'puppetlabs/ntp', :latest
    • To install a specific version, and maintain that version, specify the desired version number, as a string, after the module name. For example:
      mod 'puppetlabs/stdlib', '0.10.0'
    • To install whichever version is current during the next code deployment, and stay with that version, do not specify any options after the module name. For example:
      mod 'puppetlabs/apache'
  3. Save and commit your changes.
What to do next
Edit the Puppetfile any time you need to install a module or update a module that is not automatically updated.

With code management, you must not use the puppet module command to install or manage modules. Because code management uses the Puppetfile to install, update, and manage your modules, if you use puppet module install to install a module to the live code directory, code management deletes the module based on the Puppetfile contents.

Related information