Puppet: 4.2.1
OS: RHEL/Centos 7 (can also simulate on Windows if I set osfamily to 
'RedHat')

Most of the time I develop Puppet modules to run only on Windows but 
sometimes I want them to be able usable on other OS's particularly RHEL. 
Sometimes there's a choice between adding a bunch of predicates to a 
manifest to detect the current OS and just maintaining separate manifests. 
Notwithstanding the argumant for or against, in this particular case I 
decided to follow the latter and encountered a problem I haven't seen 
before.

Specifically it *appears* that using the OSFAMILY name as part of a class 
name[space] causes an error. Or more precisely, since I have already used 
this approach successfully with 'windows' being part of a class namespace, 
an error occurs if I use 'RedHat'.

Example:

docker_registry_host/manifests/init.pp :-

class docker_registry_host {
  ...

    notice('CLASS: docker_registry_host')
    notice('---------------------------')

    notice("osfamily = ${::osfamily}")

  ...
    include "::docker_registry_host::${::osfamily}::install"
  ...
}

docker_registry_host/manifests/RedHat/install.pp :-

class docker_registry_host::RedHat::install {

    notice('CLASS: docker_registry_host::RedHat::install')
    notice('--------------------------------------------')

}

Produces this error (full stack trace below) :-

Notice: Scope(Class[Docker_registry_host]): CLASS: docker_registry_host
Notice: Scope(Class[Docker_registry_host]): ---------------------------
Notice: Scope(Class[Docker_registry_host]):
Notice: Scope(Class[Docker_registry_host]): osfamily = RedHat

Debug: importing 
'E:/Data/git/docker_registry/puppet/environments/production/modules/docker_registry_host/manifests/RedHat/install.pp'
 
in environment production

Error: Illegal fully qualified class reference at 
E:/Data/git/docker_registry/puppet/environments/production/modules/docker_registry_host/manifests/RedHat/install.pp:4:38
 
on node lt032064.xxx.com
C:/Apps/puppet/puppet/lib/puppet/pops/parser/lexer_support.rb:32:in 
`lex_error'
C:/Apps/puppet/puppet/lib/puppet/pops/parser/lexer2.rb:536:in `lex_token'
C:/Apps/puppet/puppet/lib/puppet/pops/parser/lexer2.rb:284:in `scan'
C:/Apps/puppet/sys/ruby/lib/ruby/2.1.0/racc/parser.rb:319:in 
`_racc_yyparse_c'
C:/Apps/puppet/sys/ruby/lib/ruby/2.1.0/racc/parser.rb:319:in `yyparse'
...

So no problem finding the docker_registry_host::RedHat::install class, but 
also ... Error: Illegal fully qualified class reference ??

If I change that part of the class namespace 'foo' everything works fine :-

... so in init.pp if I use :-

    include "::docker_registry_host::foo::install"

and have the class : docker_registry_host/manifests/foo/install.pp :-

class docker_registry_host::foo::install {

    notice('CLASS: docker_registry_host::foo::install')
    notice('--------------------------------------------')
    notice('')
}

Output as expected and no error at all.

As I mentioned above, I have used include and contain statements with 
${::osfamily} in them many times before when the osfamily value resolves to 
'windows'. For example in another module I have an install class called :-

class sonatype_nexus::windows::install {

.. and it works just fine.


So I guess I'm wondering why this error occurs when osfamily resolves to 
'RedHat'.

In case it makes a difference, when I'm testing locally I'm using Centos 
rather than full-blown RHEL but running 'facter osfamily' still returns 
'RedHat'

Any ideas why this is happening (is 'RedHat' illegal in a class name[space] 
or a reserved word, or ...) ?

Kind Regards

Fraser.


Full stack trace :-

Error: Illegal fully qualified class reference at 
E:/Data/git/docker_registry/puppet/environments/production/modules/docker_registry_host/manifests/RedHat/install.pp:4:38
 
on node lt032064.xxx.com
C:/Apps/puppet/puppet/lib/puppet/pops/parser/lexer_support.rb:32:in 
`lex_error'
C:/Apps/puppet/puppet/lib/puppet/pops/parser/lexer2.rb:536:in `lex_token'
C:/Apps/puppet/puppet/lib/puppet/pops/parser/lexer2.rb:284:in `scan'
C:/Apps/puppet/sys/ruby/lib/ruby/2.1.0/racc/parser.rb:319:in 
`_racc_yyparse_c'
C:/Apps/puppet/sys/ruby/lib/ruby/2.1.0/racc/parser.rb:319:in `yyparse'
C:/Apps/puppet/puppet/lib/puppet/pops/parser/parser_support.rb:230:in 
`_parse'
C:/Apps/puppet/puppet/lib/puppet/pops/parser/parser_support.rb:79:in 
`parse_file'
C:/Apps/puppet/puppet/lib/puppet/pops/parser/evaluating_parser.rb:35:in 
`parse_file'
C:/Apps/puppet/puppet/lib/puppet/parser/e4_parser_adapter.rb:31:in `parse'
C:/Apps/puppet/puppet/lib/puppet/parser/type_loader.rb:86:in `parse_file'
C:/Apps/puppet/puppet/lib/puppet/parser/type_loader.rb:123:in `block in 
load_files'
C:/Apps/puppet/puppet/lib/puppet/parser/type_loader.rb:107:in `each'
C:/Apps/puppet/puppet/lib/puppet/parser/type_loader.rb:107:in `load_files'
C:/Apps/puppet/puppet/lib/puppet/parser/type_loader.rb:97:in 
`import_from_modules'
C:/Apps/puppet/puppet/lib/puppet/parser/type_loader.rb:68:in `block in 
try_load_fqname'
C:/Apps/puppet/puppet/lib/puppet/parser/type_loader.rb:66:in `each'
C:/Apps/puppet/puppet/lib/puppet/parser/type_loader.rb:66:in 
`try_load_fqname'
C:/Apps/puppet/puppet/lib/puppet/resource/type_collection.rb:167:in 
`find_or_load'
C:/Apps/puppet/puppet/lib/puppet/resource/type_collection.rb:116:in 
`find_hostclass'
C:/Apps/puppet/puppet/lib/puppet/parser/scope.rb:252:in `find_hostclass'
C:/Apps/puppet/puppet/lib/puppet/parser/compiler.rb:207:in `block in 
evaluate_classes'
C:/Apps/puppet/puppet/lib/puppet/parser/compiler.rb:206:in `collect'
C:/Apps/puppet/puppet/lib/puppet/parser/compiler.rb:206:in 
`evaluate_classes'
C:/Apps/puppet/puppet/lib/puppet/parser/functions/contain.rb:33:in `block 
in <top (required)>'
C:/Apps/puppet/puppet/lib/puppet/parser/functions.rb:162:in `block (2 
levels) in newfunction'
C:/Apps/puppet/puppet/lib/puppet/util/profiler/around_profiler.rb:58:in 
`profile'
C:/Apps/puppet/puppet/lib/puppet/util/profiler.rb:51:in `profile'
C:/Apps/puppet/puppet/lib/puppet/parser/functions.rb:155:in `block in 
newfunction'
C:/Apps/puppet/puppet/lib/puppet/pops/evaluator/runtime3_support.rb:281:in 
`call_function'
C:/Apps/puppet/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb:836:in 
`call_function_with_block'
C:/Apps/puppet/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb:816:in 
`eval_CallNamedFunctionExpression'
C:/Apps/puppet/puppet/lib/puppet/pops/visitor.rb:67:in `visit_this_1'
C:/Apps/puppet/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb:73:in 
`evaluate'
C:/Apps/puppet/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb:569:in 
`block in eval_BlockExpression'
C:/Apps/puppet/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb:569:in 
`each'
C:/Apps/puppet/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb:569:in 
`eval_BlockExpression'
C:/Apps/puppet/puppet/lib/puppet/pops/visitor.rb:46:in `block in visit_this'
C:/Apps/puppet/puppet/lib/puppet/pops/visitor.rb:42:in `each'
C:/Apps/puppet/puppet/lib/puppet/pops/visitor.rb:42:in `visit_this'
C:/Apps/puppet/puppet/lib/puppet/pops/visitor.rb:69:in `visit_this_1'
C:/Apps/puppet/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb:73:in 
`evaluate'
C:/Apps/puppet/puppet/lib/puppet/pops/parser/evaluating_parser.rb:57:in 
`evaluate'
C:/Apps/puppet/puppet/lib/puppet/parser/ast/pops_bridge.rb:32:in `evaluate'
C:/Apps/puppet/puppet/lib/puppet/parser/ast.rb:31:in `safeevaluate'
C:/Apps/puppet/puppet/lib/puppet/resource/type.rb:120:in `evaluate_code'
C:/Apps/puppet/puppet/lib/puppet/parser/resource.rb:79:in `evaluate'
C:/Apps/puppet/puppet/lib/puppet/parser/compiler.rb:220:in `each'
C:/Apps/puppet/puppet/lib/puppet/parser/compiler.rb:220:in 
`evaluate_classes'
C:/Apps/puppet/puppet/lib/puppet/parser/functions/include.rb:33:in `block 
in <top (required)>'
C:/Apps/puppet/puppet/lib/puppet/parser/functions.rb:162:in `block (2 
levels) in newfunction'
C:/Apps/puppet/puppet/lib/puppet/util/profiler/around_profiler.rb:58:in 
`profile'
C:/Apps/puppet/puppet/lib/puppet/util/profiler.rb:51:in `profile'
C:/Apps/puppet/puppet/lib/puppet/parser/functions.rb:155:in `block in 
newfunction'
C:/Apps/puppet/puppet/lib/puppet/pops/evaluator/runtime3_support.rb:281:in 
`call_function'
C:/Apps/puppet/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb:836:in 
`call_function_with_block'
C:/Apps/puppet/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb:816:in 
`eval_CallNamedFunctionExpression'
C:/Apps/puppet/puppet/lib/puppet/pops/visitor.rb:46:in `block in visit_this'
C:/Apps/puppet/puppet/lib/puppet/pops/visitor.rb:42:in `each'
C:/Apps/puppet/puppet/lib/puppet/pops/visitor.rb:42:in `visit_this'
C:/Apps/puppet/puppet/lib/puppet/pops/visitor.rb:69:in `visit_this_1'
C:/Apps/puppet/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb:73:in 
`evaluate'
C:/Apps/puppet/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb:640:in 
`eval_Program'
C:/Apps/puppet/puppet/lib/puppet/pops/visitor.rb:46:in `block in visit_this'
C:/Apps/puppet/puppet/lib/puppet/pops/visitor.rb:42:in `each'
C:/Apps/puppet/puppet/lib/puppet/pops/visitor.rb:42:in `visit_this'
C:/Apps/puppet/puppet/lib/puppet/pops/visitor.rb:69:in `visit_this_1'
C:/Apps/puppet/puppet/lib/puppet/pops/evaluator/evaluator_impl.rb:73:in 
`evaluate'
C:/Apps/puppet/puppet/lib/puppet/pops/parser/evaluating_parser.rb:57:in 
`evaluate'
C:/Apps/puppet/puppet/lib/puppet/parser/ast/pops_bridge.rb:105:in `evaluate'
C:/Apps/puppet/puppet/lib/puppet/parser/ast.rb:31:in `safeevaluate'
C:/Apps/puppet/puppet/lib/puppet/resource/type.rb:120:in `evaluate_code'
C:/Apps/puppet/puppet/lib/puppet/parser/resource.rb:79:in `evaluate'
C:/Apps/puppet/puppet/lib/puppet/parser/compiler.rb:409:in `evaluate_main'
C:/Apps/puppet/puppet/lib/puppet/parser/compiler.rb:131:in `block (2 
levels) in compile'
C:/Apps/puppet/puppet/lib/puppet/util/profiler/around_profiler.rb:58:in 
`profile'
C:/Apps/puppet/puppet/lib/puppet/util/profiler.rb:51:in `profile'
C:/Apps/puppet/puppet/lib/puppet/parser/compiler.rb:131:in `block in 
compile'
C:/Apps/puppet/puppet/lib/puppet/context.rb:64:in `override'
C:/Apps/puppet/puppet/lib/puppet.rb:223:in `override'
C:/Apps/puppet/puppet/lib/puppet/parser/compiler.rb:121:in `compile'
C:/Apps/puppet/puppet/lib/puppet/parser/compiler.rb:34:in `compile'
C:/Apps/puppet/puppet/lib/puppet/indirector/catalog/compiler.rb:93:in 
`block (2 levels) in compile'
C:/Apps/puppet/puppet/lib/puppet/util/profiler/around_profiler.rb:58:in 
`profile'
C:/Apps/puppet/puppet/lib/puppet/util/profiler.rb:51:in `profile'
C:/Apps/puppet/puppet/lib/puppet/indirector/catalog/compiler.rb:91:in 
`block in compile'
C:/Apps/puppet/puppet/lib/puppet/util.rb:129:in `block in benchmark'
C:/Apps/puppet/sys/ruby/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
C:/Apps/puppet/puppet/lib/puppet/util.rb:128:in `benchmark'
C:/Apps/puppet/puppet/lib/puppet/indirector/catalog/compiler.rb:90:in 
`compile'
C:/Apps/puppet/puppet/lib/puppet/indirector/catalog/compiler.rb:50:in `find'
C:/Apps/puppet/puppet/lib/puppet/indirector/indirection.rb:194:in `find'
C:/Apps/puppet/puppet/lib/puppet/application/apply.rb:256:in `block in main'
C:/Apps/puppet/puppet/lib/puppet/context.rb:64:in `override'
C:/Apps/puppet/puppet/lib/puppet.rb:223:in `override'
C:/Apps/puppet/puppet/lib/puppet/application/apply.rb:225:in `main'
C:/Apps/puppet/puppet/lib/puppet/application/apply.rb:170:in `run_command'
C:/Apps/puppet/puppet/lib/puppet/application.rb:344:in `block in run'
C:/Apps/puppet/puppet/lib/puppet/util.rb:446:in `exit_on_fail'
C:/Apps/puppet/puppet/lib/puppet/application.rb:344:in `run'
C:/Apps/puppet/puppet/lib/puppet/util/command_line.rb:128:in `run'
C:/Apps/puppet/puppet/lib/puppet/util/command_line.rb:72:in `execute'
C:/Apps/puppet/puppet/bin/puppet:5:in `<main>'

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/93261d69-4d76-490b-a255-28eb98a5d664%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to