Re: [Puppet Users] nested modules and autoloading

2012-09-28 Thread Tim Mooney

In regard to: Re: [Puppet Users] nested modules and autoloading, Martin...:


Hi Tim,

please check your class and file names.

The following is working:

modules/http/manifests/init.pp
class  'http' {
include http::config_file
}

modules/http/manifests/config_file.pp
class http::config_file {
file { '/tmp/http':
content => 'http',
}
}


Martin-

I found the problem, and it was something simple.

I was originally confused because I had expected that

include mymodule::special_type

should work if I had

modules/mymodule/manifests/special_type/init.pp

but it does not.  When I tried

modules/mymodule/manifests/special_type.pp

and that didn't work, I thought there was a general problem with
nested classes that I wasn't understanding.

The actual problem was that I hadn't committed
modules/mymodule/manifests/special_type.pp to our VCS.  :-|  Oops.

Thanks,

Tim


On 28.09.2012, at 12:53, Tim Mooney wrote:



All-

I'm using puppet 2.7.14.  I've reviewed

 http://docs.puppetlabs.com/puppet/2.7/reference/modules_fundamentals.html

but it doesn't seem to cover what I'm attempting.

Consider a module layout like this:

$ tree mymodule
mymodule
|-- Modulefile
|-- README
|-- manifests
|   |-- init.pp
|   |-- special_type
|   |   `-- prereqs.pp
|   `-- special_type.pp
|-- spec
|   `-- spec_helper.rb
`-- tests
   `-- init.pp

4 directories, 7 files


$ egrep -v '^#|^$' mymodule/manifests/init.pp class mymodule($type = 
hiera('mymodule_type', 'client')) {
 case $type {
   'client' : {  }
   'custom' : {  }
   'special_type'   : { include mymodule::special_type }
   default  : { fail("Unknown mymodule_type=${mymodule_type}\n") }
 }
}


The problem is the "include mymodule::special_type".  I've tried both
having

mymodule/manifests/special_type/init.pp

as well as just

mymodule/manifests/special_type.pp

In both cases, doing this in a node definition:

 class { 'mymodule':
   type => 'special_type',
 }

results in

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could 
not find class mymodule::special_type for host.ndsu.edu at 
/etc/puppet/modules/mymodule/manifests/init.pp:41 on node host.ndsu.edu

Is it even possible to do what I'm attempting?  I know that

 http://docs.puppetlabs.com/puppet/2.7/reference/modules_fundamentals.html

discusses nested "implementation" modules, but there's only examples of
loading specific implementations, e.g.

include my_module::implementation::foo

rather than

include my_module::implementation


I know from plenty of first-hand experience that another reason why I
might see a "could not find class " is if I have a typo in the
class name within the .pp file, but I've reviewed the classes involved
here and don't see any problems.

Any thoughts on whether it's possible to load the "top level" of a nested
class?

Tim
--
Tim Mooney tim.moo...@ndsu.edu
Enterprise Computing & Infrastructure  701-231-1076 (Voice)
Room 242-J6, IACC Building 701-231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.






--
Tim Mooney tim.moo...@ndsu.edu
Enterprise Computing & Infrastructure  701-231-1076 (Voice)
Room 242-J6, IACC Building 701-231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] nested modules and autoloading

2012-09-28 Thread Martin Alfke
Hi Tim,

please check your class and file names.

The following is working:

modules/http/manifests/init.pp
class  'http' {
include http::config_file
}

modules/http/manifests/config_file.pp
class http::config_file {
file { '/tmp/http':
content => 'http',
}
}

modules/http/tests/init.pp
include http

puppet apply -v modules/http/tests/init.pp
will create /tmp/http file resource.

http://docs.puppetlabs.com/puppet/2.7/reference/lang_reserved.html

- Martin


On 28.09.2012, at 12:53, Tim Mooney wrote:

> 
> All-
> 
> I'm using puppet 2.7.14.  I've reviewed
> 
>  http://docs.puppetlabs.com/puppet/2.7/reference/modules_fundamentals.html
> 
> but it doesn't seem to cover what I'm attempting.
> 
> Consider a module layout like this:
> 
> $ tree mymodule
> mymodule
> |-- Modulefile
> |-- README
> |-- manifests
> |   |-- init.pp
> |   |-- special_type
> |   |   `-- prereqs.pp
> |   `-- special_type.pp
> |-- spec
> |   `-- spec_helper.rb
> `-- tests
>`-- init.pp
> 
> 4 directories, 7 files
> 
> 
> $ egrep -v '^#|^$' mymodule/manifests/init.pp class mymodule($type = 
> hiera('mymodule_type', 'client')) {
>  case $type {
>'client' : {  }
>'custom' : {  }
>'special_type'   : { include mymodule::special_type }
>default  : { fail("Unknown mymodule_type=${mymodule_type}\n") }
>  }
> }
> 
> 
> The problem is the "include mymodule::special_type".  I've tried both
> having
> 
> mymodule/manifests/special_type/init.pp
> 
> as well as just
> 
> mymodule/manifests/special_type.pp
> 
> In both cases, doing this in a node definition:
> 
>  class { 'mymodule':
>type => 'special_type',
>  }
> 
> results in
> 
> err: Could not retrieve catalog from remote server: Error 400 on SERVER: 
> Could not find class mymodule::special_type for host.ndsu.edu at 
> /etc/puppet/modules/mymodule/manifests/init.pp:41 on node host.ndsu.edu
> 
> Is it even possible to do what I'm attempting?  I know that
> 
>  http://docs.puppetlabs.com/puppet/2.7/reference/modules_fundamentals.html
> 
> discusses nested "implementation" modules, but there's only examples of
> loading specific implementations, e.g.
> 
>   include my_module::implementation::foo
> 
> rather than
> 
>   include my_module::implementation
> 
> 
> I know from plenty of first-hand experience that another reason why I
> might see a "could not find class " is if I have a typo in the
> class name within the .pp file, but I've reviewed the classes involved
> here and don't see any problems.
> 
> Any thoughts on whether it's possible to load the "top level" of a nested
> class?
> 
> Tim
> -- 
> Tim Mooney tim.moo...@ndsu.edu
> Enterprise Computing & Infrastructure  701-231-1076 (Voice)
> Room 242-J6, IACC Building 701-231-8541 (Fax)
> North Dakota State University, Fargo, ND 58105-5164
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/puppet-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] nested modules and autoloading

2012-09-28 Thread Tim Mooney


All-

I'm using puppet 2.7.14.  I've reviewed

  http://docs.puppetlabs.com/puppet/2.7/reference/modules_fundamentals.html

but it doesn't seem to cover what I'm attempting.

Consider a module layout like this:

$ tree mymodule
mymodule
|-- Modulefile
|-- README
|-- manifests
|   |-- init.pp
|   |-- special_type
|   |   `-- prereqs.pp
|   `-- special_type.pp
|-- spec
|   `-- spec_helper.rb
`-- tests
`-- init.pp

4 directories, 7 files


$ egrep -v '^#|^$' mymodule/manifests/init.pp 
class mymodule($type = hiera('mymodule_type', 'client')) {

  case $type {
'client' : {  }
'custom' : {  }
'special_type'   : { include mymodule::special_type }
default  : { fail("Unknown mymodule_type=${mymodule_type}\n") }
  }
}


The problem is the "include mymodule::special_type".  I've tried both
having

mymodule/manifests/special_type/init.pp

as well as just

mymodule/manifests/special_type.pp

In both cases, doing this in a node definition:

  class { 'mymodule':
type => 'special_type',
  }

results in

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could 
not find class mymodule::special_type for host.ndsu.edu at 
/etc/puppet/modules/mymodule/manifests/init.pp:41 on node host.ndsu.edu

Is it even possible to do what I'm attempting?  I know that

  http://docs.puppetlabs.com/puppet/2.7/reference/modules_fundamentals.html

discusses nested "implementation" modules, but there's only examples of
loading specific implementations, e.g.

include my_module::implementation::foo

rather than

include my_module::implementation


I know from plenty of first-hand experience that another reason why I
might see a "could not find class " is if I have a typo in the
class name within the .pp file, but I've reviewed the classes involved
here and don't see any problems.

Any thoughts on whether it's possible to load the "top level" of a nested
class?

Tim
--
Tim Mooney tim.moo...@ndsu.edu
Enterprise Computing & Infrastructure  701-231-1076 (Voice)
Room 242-J6, IACC Building 701-231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.