Puppet Setting Deprecation

56 views
Skip to first unread message

Nan Liu

unread,
Sep 4, 2014, 1:03:12 PM9/4/14
to puppe...@googlegroups.com
I have some code that's doing module searching in the module path:

example = Puppet::Module.find('example', Puppet[:environment].to_s)
raise(LoadError, "Unable to find example module in modulepath
#{Puppet[:modulepath]}") unless example

In Puppet 3.6, the second line is triggering a the following warning:
Warning: Accessing 'modulepath' as a setting is deprecated. See
http://links.puppetlabs.com/env-settings-deprecations

I was able to trace the changes to PUP-2650, but it's not really clear
where the setting is stored now. What's the correct way to access the
modulepath configuration in 3.6?

Thanks,

Nan

Trevor Vaughan

unread,
Sep 4, 2014, 1:08:48 PM9/4/14
to puppe...@googlegroups.com
I think it's Puppet[:basemodulepath] but this needs to be combined with your environment path search.

Trevor




--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/54089B49.40304%40gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699
tvau...@onyxpoint.com

-- This account not approved for unencrypted proprietary information --

Joshua Partlow

unread,
Sep 4, 2014, 2:28:01 PM9/4/14
to puppe...@googlegroups.com
Hi Nan,

The modulepath is really only meaningful from an actual environment instance.  What code are you writing?  You'll probably want to lookup the current environment or make use of the environment instance available in your local context (if there is one).


To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/CANs%2BFoWMs_%2B3_N3HECGeUsBxOO62VdrLrA6aAjd97fjn_Vx4yQ%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Josh Partlow
jpar...@puppetlabs.com
Developer, Puppet Labs

Join us at PuppetConf 2014, September 20-24 in San Francisco
Register by September 8th to take advantage of the Final Countdown —save $149!

Nan Liu

unread,
Sep 4, 2014, 3:35:06 PM9/4/14
to puppet-dev
Yes, I'm looking for the environment specific modulepath.

Maybe this is a more complete example:
example = Puppet::Module.find('example', Puppet[:environment].to_s)
raise(LoadError, "Unable to find example module in modulepath #{Puppet[:modulepath]}") unless example
YAML.load_file(File.join(example.path, 'data/foo.yaml'))

So for the directory below:
/etc/puppet/environment/production/modules/example/data/foo.yaml
/etc/puppet/environment/test/modules/example/data/foo.yaml
/etc/puppet/environment/qa/modules/

When an agent connections to environment qa, the error message should be:
Unable to find example module in modulepath /etc/puppet/environment/qa/modules/

I haven't had a chance to spin up a test master to see if Puppet[:basemodulepath] works yet, but it seems to work in irb.

Thanks,

Nan

Joshua Partlow

unread,
Sep 4, 2014, 4:06:08 PM9/4/14
to puppe...@googlegroups.com
On Thu, Sep 4, 2014 at 12:34 PM, Nan Liu <nan...@gmail.com> wrote:
Yes, I'm looking for the environment specific modulepath.

Maybe this is a more complete example:
example = Puppet::Module.find('example', Puppet[:environment].to_s)
raise(LoadError, "Unable to find example module in modulepath #{Puppet[:modulepath]}") unless example
YAML.load_file(File.join(example.path, 'data/foo.yaml'))

Where will this code be executing?  On the master, during a catalog compilation?  If so, you probably want:

environment = Puppet.lookup(:current_environment)
environment.modulepath
 

For more options, visit https://groups.google.com/d/optout.

Andy Parker

unread,
Sep 4, 2014, 4:14:44 PM9/4/14
to puppe...@googlegroups.com
On Thu, Sep 4, 2014 at 1:05 PM, Joshua Partlow <joshua....@puppetlabs.com> wrote:
On Thu, Sep 4, 2014 at 12:34 PM, Nan Liu <nan...@gmail.com> wrote:
Yes, I'm looking for the environment specific modulepath.

Maybe this is a more complete example:
example = Puppet::Module.find('example', Puppet[:environment].to_s)
raise(LoadError, "Unable to find example module in modulepath #{Puppet[:modulepath]}") unless example
YAML.load_file(File.join(example.path, 'data/foo.yaml'))

Where will this code be executing?  On the master, during a catalog compilation?  If so, you probably want:

environment = Puppet.lookup(:current_environment)
environment.modulepath

and

  mod = environment.module('example')

to get the module from the environment.
 

For more options, visit https://groups.google.com/d/optout.



--
Andrew Parker
Freenode: zaphod42
Twitter: @aparker42
Software Developer

Join us at PuppetConf 2014September 22-24 in San Francisco
Register by May 30th to take advantage of the Early Adopter discount save $349!

Nan Liu

unread,
Sep 4, 2014, 4:26:14 PM9/4/14
to puppet-dev
On Thu, Sep 4, 2014 at 1:14 PM, Andy Parker <an...@puppetlabs.com> wrote:
On Thu, Sep 4, 2014 at 1:05 PM, Joshua Partlow <joshua....@puppetlabs.com> wrote:
On Thu, Sep 4, 2014 at 12:34 PM, Nan Liu <nan...@gmail.com> wrote:
Yes, I'm looking for the environment specific modulepath.

Maybe this is a more complete example:
example = Puppet::Module.find('example', Puppet[:environment].to_s)
raise(LoadError, "Unable to find example module in modulepath #{Puppet[:modulepath]}") unless example
YAML.load_file(File.join(example.path, 'data/foo.yaml'))

Where will this code be executing?  On the master, during a catalog compilation?  If so, you probably want:

Yep. 

environment = Puppet.lookup(:current_environment)
environment.modulepath

and

  mod = environment.module('example')

to get the module from the environment.

This is exactly what I was looking for. Thanks!

Nan 
Reply all
Reply to author
Forward
0 new messages