Declare content from a relative control repo branch

If you declare a Git repository to track a specific branch, you can also specify the :control_branch option, which allows you to deploy content from a control repo branch relative to the location of the Puppetfile.

Before you begin: The :control_branch option is a modification of the :branch option, which you can use to Keep repository content at a specific version .

Normally, :branch tracks a specifically-named repository branch, such as testing, or a specific feature branch. If you specify :branch => :control_branch, it locates and tracks a branch in the Git repository that has the same name as the control repo branch where the Puppetfile is located.

For example, if your Puppetfile is in the production branch, content from the Git repo's production branch is deployed. Similarly, if you copy this Puppetfile to your testing branch, the tracking from that branch follows the Git repo's testing branch.

With :control_branch, when you create new branches, you don't have to edit the inherited Puppetfile as extensively, because the tracked branches remain relative. However, your Git repository branch names must match your control repo's branch names for the :control_branch option to work successfully. You might want to Set a default branch for content deployment as a backup in case no matching branch is found.

Here is an example of a declaration using :control_branch:

mod 'hieradata',
  :git    => 'git@git.example.com:organization/hieradata.git',
  :branch => :control_branch