Issue #19638 has been updated by Charlie Sharpsteen.

Status changed from Unreviewed to Rejected
Assignee set to Charlie Sharpsteen

According to the [import 
documentation](http://docs.puppetlabs.com/puppet/3/reference/lang_import.html#interactions-with-the-autoloader),
 the use of import inside autoloaded manifests is undefined and specifically:

> You should never place import statements in modules; they should only exist 
> in site.pp

----------------------------------------
Bug #19638: puppet master fails to correctly classes the first time around when 
"import" is in play
https://projects.puppetlabs.com/issues/19638#change-91784

* Author: David Schmitt
* Status: Rejected
* Priority: Normal
* Assignee: Charlie Sharpsteen
* Category: 
* Target version: 
* Affected Puppet version: 3.0.1
* Keywords: 
* Branch: 
----------------------------------------
As a workaround for another tool I tried putting the icinga() class of my 
icinga module into manifests/icinga.pp instead of manifests/init.pp and import 
the former in the latter. This lead to the "interesting" situation, that the 
puppet master would not find the class the first time it was asked for it. 
Running under passenger, the process would stay around and the next request 
would work without a problem.


puppet 3.0.1 running on "Red Hat Enterprise Linux Server release 6.3 
(Santiago)":

    Debug: importing 
'/srv/puppet/environments/hiera/modules/icinga/manifests/init.pp' in 
environment hiera
    Debug: importing 
'/srv/puppet/environments/hiera/modules/icinga/manifests/implementation/conffile.pp'
 in environment hiera
    Debug: importing 
'/srv/puppet/environments/hiera/modules/icinga/manifests/implementation/contact.pp'
 in environment hiera
    Debug: importing 
'/srv/puppet/environments/hiera/modules/icinga/manifests/icinga.pp' in 
environment hiera
    Error: Could not find class icinga for client.example.com on node 
client.example.com
    /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:167:in 
`evaluate_classes'
    /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:150:in `each'
    /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:150:in 
`evaluate_classes'
    /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:127:in 
`evaluate_node_classes'
    /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:100:in `compile'
    /usr/lib/ruby/site_ruby/1.8/puppet/parser/compiler.rb:29:in `compile'
    /usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:77:in 
`compile'
    /usr/lib/ruby/site_ruby/1.8/puppet/util.rb:179:in `benchmark'
    /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime'
    /usr/lib/ruby/site_ruby/1.8/puppet/util.rb:178:in `benchmark'
    /usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:75:in 
`compile'
    /usr/lib/ruby/site_ruby/1.8/puppet/indirector/catalog/compiler.rb:35:in 
`find'
    /usr/lib/ruby/site_ruby/1.8/puppet/indirector/indirection.rb:191:in `find'
    /usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:108:in `do_find'
    /usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:71:in `send'
    /usr/lib/ruby/site_ruby/1.8/puppet/network/http/handler.rb:71:in `process'
    /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick/rest.rb:24:in 
`service'
    /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
    /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
    /usr/lib/ruby/site_ruby/1.8/puppet/network/http/webrick.rb:33:in `listen'
    [...]

icinga/manifests/init.pp:

    import "implementation/*.pp"
    import "icinga.pp"
    
icinga/manifests/icinga.pp:

    # class icinga(
    #     $role: icinga::$role will be included to actually configure resources
    #     $address: use this instead of the hostname to check this host
    #     $admins: comma separated list of people responsible for this host
    #     $server: central server surfacing this host's checks
    #     $sensor: icinga server that's talking to us
    #     $parents: failure-topological parents of this host
    #     $project: name of the primary hostgroup
    #     $notifications: 1 if notifications shall be sent out for this host, 0 
if not
    class icinga ($role = 'monitored', $address = '', $admins, $server, 
$sensor_override = '', $parents = '', $project, $notifications) 
    {
    $sensor = $sensor_override ? {
    ''      => $server,
    default => $sensor_override
    }
    $groups = $project ? {
    ''      => ['servers'],
    default => [$project]
    }
    include "icinga::${role}"
    }

This also happened with a different parameterized class in a different module.

I'm aware that the use of import is discouraged, and I've already been able to 
remove this workaround, so I'm not triggering the problem anymore, but perhaps 
it's an easy fix.



-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to