Puppet: System Administration Automated

Support

Ticket #1175 (assigned defect)

Opened 8 months ago

Last modified 6 months ago

Custom function doesn't work when using multiple environments

Reported by: eugene Assigned to: luke (accepted)
Priority: normal Milestone: 0.24.5
Component: language Version: 0.24.4
Severity: critical Keywords:
Cc: Triage Stage: Accepted
Attached Patches: None Complexity: Medium

Description

Environments settings in puppet.conf:

client:

[main]
    environment = production

server:

[main]
    environments = production,development

[production]
    manifest = /usr/local/etc/puppet/manifests/production/site.pp
    modulepath = /usr/local/etc/puppet/modules/production

I have module for postfix configuration with custom function

My postfix module located in /usr/local/etc/puppet/modules/production/postfix and my custom function in /usr/local/etc/puppet/modules/production/postfix/plugins/puppet/parser/functions.

I get the following error running puppet client:

err: Could not retrieve catalog: Unknown function .... at /usr/local/etc/puppet/modules/production/postfix/manifests/init.pp:60 on node .....

If I disable using this function in postfix/manifests/init.pp module works.

If I use setup without environments with configuration:

[main]
    manifest = /usr/local/etc/puppet/manifests/site.pp
    modulepath = /usr/local/etc/puppet/modules

and place module into /usr/local/etc/puppet/modules/postfix and function into /usr/local/etc/puppet/modules/postfix/plugins/puppet/parser/functions

everything works as expected.

os version: FreeBSD-6.2 puppet version: 0.24.4

Attachments

sample.tgz (479 bytes) - added by eugene on 04/08/08 09:58:55.
Sample module

Change History

(follow-up: ↓ 5 ) 04/03/08 14:00:56 changed by Fujin

  • status changed from new to assigned.
  • severity changed from normal to minor.
  • component changed from server to library.
  • priority changed from normal to low.
  • milestone set to unplanned.
  • owner changed from community to Fujin.
  • stage changed from Unreviewed to Needs more info.

Unable to replicate.

puppet.conf:

[main]
environments=production,testing

[production]
manifest=/etc/puppet/env/production/site.pp
modulepath=/etc/puppet/env/production/modules

[puppetd]
environment=production

tests (gsub is a parser function provided by DavidS' common module):

root@junglist (branch: master) /etc/puppet/env/production# cat site.pp
node junglist {
   $ifs = gsub(split($interfaces, " "), "(.+)", "if_\\1")
   notify {
      $ifs:
   }
}
root@junglist (branch: master) /etc/puppet/env/production# puppetd --test --environment production
info: Loading fact configured_ntp_servers
info: Loading fact netmask
info: Loading fact acpi_available
info: Loading fact interfaces
info: Retrieving plugins
notice: Ignoring cache
info: Caching catalog at /var/lib/puppet/state/localconfig.yaml
notice: Starting catalog run
notice: if_eth0,eth0:0,eth0:1,eth0:2,eth0:3,eth1
notice: Finished catalog run in 1.08 seconds

Please provide more details, with specific replication steps if possible.

04/03/08 14:02:00 changed by Fujin

  • owner changed from Fujin to eugene.
  • status changed from assigned to new.

04/03/08 14:02:15 changed by Fujin

  • owner changed from eugene to Fujin.
  • status changed from new to assigned.

04/03/08 17:41:40 changed by luke

  • priority changed from low to normal.
  • complexity changed from Unknown to Medium.
  • stage changed from Needs more info to Accepted.

I can basically guarantee that this bug is valid, because all functions are dynamically defined on the Scope class, which means that they're global to environments.

The only real fix is to move the functions to a stand-alone class or module and make that module be per-environment, or to keep the functions as just blocks, looking up and evaluating them as necessary.

04/08/08 09:58:55 changed by eugene

  • attachment sample.tgz added.

Sample module

(in reply to: ↑ 1 ) 04/08/08 10:03:00 changed by eugene

Please provide more details, with specific replication steps if possible.

See attachment:sample.tgz

This sample module works in setup without environments and doesn't work when using environments

04/11/08 00:01:38 changed by immerda

  • severity changed from minor to critical.

I can confirme this behaviour. I even tried to manually sync the functions, however they always got overwritten/emptied before compiling and then this failed.

Disabling environments just work fine.

This bug is kind of critical and a bit a locker of proceeding people to newer versions, if they want to use environments.

As Luke mentioned in a mail this fix won't be quite easy to fix. So where would be the best place to start to investigate? How can people help?

(follow-up: ↓ 10 ) 04/23/08 16:16:06 changed by DavidS

After a bit debugging with immerda, we found out that setting an additional global modulepath at least lets the puppetmaster work with those functions, even when using environments.

I'm running with this configuration already for quite a while and ahd no unexpected problems with it:

[main]
environment=production
# Default modulepath without environments
modulepath=/srv/puppet/modules:/etc/puppet/modules:/usr/share/puppet/modules

[production]
modulepath=/srv/puppet/modules:/etc/puppet/modules:/usr/share/puppet/modules

[development]
modulepath=/srv/puppet/modules-development:/etc/puppet/modules:/usr/share/puppet/modules

04/24/08 07:25:10 changed by luke

  • component changed from library to language.

05/08/08 16:30:40 changed by luke

  • milestone changed from unplanned to 0.24.5.

(in reply to: ↑ 7 ) 05/13/08 06:54:15 changed by Fujin

  • owner changed from Fujin to community.
  • status changed from assigned to new.

I'd go so far as to say that the workaround below is sufficient, and I'm not familiar enough with the underlying substructures to actually implement the work suggested by Luke, as such, here you go community!

Replying to DavidS:

After a bit debugging with immerda, we found out that setting an additional global modulepath at least lets the puppetmaster work with those functions, even when using environments. I'm running with this configuration already for quite a while and ahd no unexpected problems with it: {{{ [main] environment=production # Default modulepath without environments modulepath=/srv/puppet/modules:/etc/puppet/modules:/usr/share/puppet/modules [production] modulepath=/srv/puppet/modules:/etc/puppet/modules:/usr/share/puppet/modules [development] modulepath=/srv/puppet/modules-development:/etc/puppet/modules:/usr/share/puppet/modules }}}

05/16/08 06:16:38 changed by luke

  • owner changed from community to luke.
  • status changed from new to assigned.