Skip to content

Latest commit

 

History

History
119 lines (87 loc) · 4.67 KB

faq.mkd

File metadata and controls

119 lines (87 loc) · 4.67 KB

Frequently Asked Questions

The default Git branch is 'master', while the default Puppet environment is 'production'. How do I reconcile this?

The default Git branch name is 'master', but this is a somewhat arbitrary name and doesn't necessarily map to every use case. In the case of R10K it's generally easiest to rename 'master' to 'production'. You can rename the master branch with the following:

git branch -m master production
git push --set-upstream origin production

Note that this will only create a new branch called production with a copy of master - to change the default branch for all subsequent clones, read on.

Changing the default branch for bare Git repositories

When you clone a repository, Git checks out the currently active branch on the remote repository. Changing this for a non-bare repository is simple - just check out a different branch and subsequent clones from that repository will use that branch.

For bare repositories things are a bit more complex. Bare repositories do not have a working directory that can be checked out, but they do have a symbolic ref that serves the same role. To change this, run the following command:

git --git-dir /path/to/bare/repo symbolic-ref HEAD refs/heads/production

Changing the default branch for different Git services

For Git hosting services where you may not cannot directly invoke commands, there are usually administrative tools to allow you to change the default branch on your remote repositories:

How do I prevent r10k from removing modules in the /modules directory of my Git repository?

By default, r10k will install modules specified in the Puppetfile into the /modules directory of each environment, but if you already use that directory and keep modules in it, r10k may think those modules are not meant to exist and may remove them.

There are three ways of fixing this: including your local modules in the Puppetfile, moving the directory where r10k install Puppetfile sourced modules, or moving your modules.

Including your local modules in the Puppetfile

The Puppetfile has a concept of a "local" module, otherwise known as a module that r10k did not directly placed there but should not be removed. If you want to continue keep your modules in the /modules directory and still install external modules from the Puppetfile into that directory, you can add a mod directive to the Puppetfile for each of your local modules.


mod 'my_ntp', :local => true
mod 'roles', :local => true
mod 'profiles', :local => true

# Include your external modules as usual
mod 'puppetlabs/stdlib'
mod 'puppetlabs/apache'

Move where the Puppetfile installs external modules

Instead of having to add a module entry for each of your local modules, you can simply move where the Puppetfile installs modules with the moduledir setting.

# The moduledir setting must be set before any modules are created
moduledir "external-modules"

mod 'puppetlabs/stdlib'
mod 'puppetlabs/apache'

In Puppet 3.6 and later you can create an environment.conf in the root of your environment to indicate which directories contain modules:

# environment.conf
modulepath = modules:external-modules

Move your local modules

Lastly, you can simply move your locally versioned modules to a separate directory to avoid conflicting over the /modules directory entirely. With this example as well you can use the `environment.conf file to tell Puppet which directories contain modules.

# environment.conf
modulepath = internal-modules:modules

What does the name mean?

It's explained in this blog post.