puppetlabs/puppet — pull request #884 by jeffmccune (2012-06-26 05:01:26+00:00)
Title: Ticket/3.0rc/15202 puppet should create directories when installing modules

Without this patch, the puppet module install command will fail when run
as a normal user account without a ~/.puppet directory.

The error is:

$ puppet module install puppetlabs-cloud_provisioner
Preparing to install into /Users/jeff/.puppet/modules ...
Error: Could not install module 'puppetlabs-cloud_provisioner' (latest)
Directory /Users/jeff/.puppet/modules does not exist

This is a problem because it adds friction to the process of getting started
with Puppet.

This patch fixes the problem by creating the directory if the path does not
already exist. If the path does exist, then the error is still thrown, but has
been modified slightly to provide helpful next actions. The error when the
path exists as a non-directory looks like:

Error: Could not install module 'puppetlabs-cloud_provisioner' (latest)
The reason is path '/Users/jeff/.puppet/modules' is not a directory.
A potential solution is `mkdir -p '/Users/jeff/.puppet/modules'`.

This patch also handles the situation where the target path does not exist but
the effective uid of the puppet process does not have access to create the
directory. The error message in this case looks like:

Error: Could not install module 'puppetlabs-cloud_provisioner' (latest)
Permission is denied when trying to create directory '/Users/jeff/.puppet/modules'.
A potential solution is to check the ownership and permissions of parent directories.