Create a Puppetfile
The Puppetfile manages an environment's content. When
you create a Puppetfile, use the mod
directive to declare an environment's content.
You must be Managing environments with a control repository. These steps assume you have set up a control repository that has the
production
branch as the default
branch.These steps explain how to create an initial Puppetfile in your production
environment (which is usually the
default environment). This initial Puppetfile becomes a
template for your other environments. When you Add an environment (by
creating a branch based on the default branch), the new environment inherits a copy of the
default environment's Puppetfile, which you can then modify
on the new branch to declare the new environment's content.
- On your
production
branch, in the root directory, create a text file namedPuppetfile
. - Open the new
Puppetfile
in a text editor, such as VS Code. - Declare the
production
environment's content in the Puppetfile.Use a
mod
directive to specify each module or repository. Additionally, you need to define the name of the content and any other information code management needs to correctly install and maintain the declared modules and data. For information and examples of Puppetfile declarations, refer to: - Optional: If you want code management to install modules somewhere other than the default
directory (
./modules
), use themoduledir
directive to Change the module installation directory. - Save and commit your changes.
If you already have multiple branches (environments) in your control repo, you might need to copy the Puppetfile to the other branches, and then edit each copy according to each environment's module and data requirements. When you Add an environment, the new branch automatically gets a copy of the Puppetfile that you can then edit accordingly for the new environment.
Creating a Puppetfile is a requirement for Managing code with Code Manager or Managing code with r10k.