When writing modules, is it required that then entry point be named init.pp?
I have written a module and if I try to call the module via nodes.pp from a
file named other than init.pp, I get an error that the module cannot be
found. If I rename the file to init.pp, it works fine.
So, can someone clarify, is the naming of the file a requirement?
ssh.pp
class ssh::hostkeys{
@@sshkey { "${fqdn}_dsa":
host_aliases => [ "$fqdn", "$hostname",
"$ipaddress" ],
type => dsa,
key => $sshdsakey,
}
@@sshkey { "${fqdn}_rsa":
host_aliases => [ "$fqdn", "$hostname",
"$ipaddress" ],
type => rsa,
key => $sshrsakey,
}
Sshkey <<| |>>
}
_________________________________________________________
init.pp
class ssh::hostkeys{
@@sshkey { "${fqdn}_dsa":
host_aliases => [ "$fqdn", "$hostname",
"$ipaddress" ],
type => dsa,
key => $sshdsakey,
}
@@sshkey { "${fqdn}_rsa":
host_aliases => [ "$fqdn", "$hostname",
"$ipaddress" ],
type => rsa,
key => $sshrsakey,
}
Sshkey <<| |>>
}
_____________________________________________________________
nodes.pp
node ''default'' {
include test
include motd
#include sudoers
include user::virtual
include user::developers
include ssh::hostkeys
include ssh::knownhosts
}
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
On 03/07/2012 17:28, Worker Bee wrote:> When writing modules, is it required that then entry point be named > init.pp? > > I have written a module and if I try to call the module via nodes.pp > from a file named other than init.pp, I get an error that the module > cannot be found. If I rename the file to init.pp, it works fine. > > So, can someone clarify, is the naming of the file a requirement? > > ssh.pp > > class ssh::hostkeys{Yes, the autoloader will look in init.pp for the class named "modulename" and will look for modulename::subclassname in subclassname.pp... eg: # manifests/init.pp class ssh { # manifests/hostkeys.pp class ssh::hostkeys { Craig -- Craig Dunn Professional Services Puppet Labs Inc. http://www.puppetlabs.com -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Craig;
Thank you for your repl(ies)!
However, this leaves me puzzled that I may not fully understand the way
stored configs/modules work.
I have another module that does not have an init.pp and it works??
class user::virtual
{
@user {fabauto:
ensure => present,
comment => "FabricAutomation_account"}
@user {graham: ensure => present}
@user {steven: ensure => present}
@user {grace: ensure => present}
}
__________________________________
node ''default'' {
include test
include motd
#include sudoers
include user::virtual
include user::developers
include ssh::hostkeys
include ssh::knownhosts
}
Thanks so much for the help!
On Tue, Jul 3, 2012 at 12:34 PM, Craig Dunn <craig@puppetlabs.com> wrote:
> On 03/07/2012 17:28, Worker Bee wrote:
>
>> When writing modules, is it required that then entry point be named
>> init.pp?
>>
>> I have written a module and if I try to call the module via nodes.pp
from
>> a file named other than init.pp, I get an error that the module cannot
be
>> found. If I rename the file to init.pp, it works fine.
>>
>> So, can someone clarify, is the naming of the file a requirement?
>>
>> ssh.pp
>>
>> class ssh::hostkeys{
>>
> Yes, the autoloader will look in init.pp for the class named
"modulename"
> and will look for modulename::subclassname in subclassname.pp... eg:
>
> # manifests/init.pp
> class ssh {
>
> # manifests/hostkeys.pp
> class ssh::hostkeys {
>
> Craig
>
> --
> Craig Dunn
> Professional Services
> Puppet Labs Inc.
> http://www.puppetlabs.com
>
> --
> 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+unsubscribe@**
> googlegroups.com <puppet-users%2Bunsubscribe@googlegroups.com>.
> For more options, visit this group at http://groups.google.com/**
>
group/puppet-users?hl=en<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+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.
> However, this leaves me puzzled that I may not fully understand the > way stored configs/modules work. > > I have another module that does not have an init.pp and it works?? > > > class user::virtual > {init.pp is not mandatory for a module per se, but it is the place the autoloader will look for a class named "user" - in this example, you don''t have a user class, just a user::virtual class, so.. include user::virtual ... will direct the autoloader to look in <modulepath>/user/manifests/virtual.pp If you were to want to add a class named user, you would put this in a file called init.pp. Does that make more sense? Craig -- Craig Dunn Professional Services Puppet Labs Inc. http://www.puppetlabs.com -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
yes! that clarified things! I get it now and realize it was a silly question... light bulb is now on! Thank you and have a great weekend! On Tue, Jul 3, 2012 at 12:50 PM, Craig Dunn <craig@puppetlabs.com> wrote:> > However, this leaves me puzzled that I may not fully understand the way >> stored configs/modules work. >> >> I have another module that does not have an init.pp and it works?? >> >> >> class user::virtual >> { >> > > init.pp is not mandatory for a module per se, but it is the place the > autoloader will look for a class named "user" - in this example, you don''t > have a user class, just a user::virtual class, so.. > > include user::virtual > > ... will direct the autoloader to look in <modulepath>/user/manifests/** > virtual.pp > > If you were to want to add a class named user, you would put this in a > file called init.pp. > > Does that make more sense? > > Craig > > -- > Craig Dunn > Professional Services > Puppet Labs Inc. > http://www.puppetlabs.com > > -- > 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+unsubscribe@** > googlegroups.com <puppet-users%2Bunsubscribe@googlegroups.com>. > For more options, visit this group at http://groups.google.com/** > group/puppet-users?hl=en<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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.