Kodiak Firesmith
2013-Jan-31 15:07 UTC
[Puppet Users] Calling a "subclass" correctly in a node def?
Hi Guys! I played with this a bit and perused the Puppet3 docs, and tried a few different ways of calling the module with no joy before giving in and posting. I''m kind of new to all this so bear with me. *Goal of module* Singular module to hold both a mysql (client) and mysql-server class. Module default would be ''mysql'', or for mysql-servers we''ll call mysql::mysql-server which inherits mysql (client). *Environment *RHEL 6 & Puppet 3.0.2 *Module code* class mysql { package { ''mysql'': ensure => present, before => [ File[''/etc/my.cnf''], ], } file { "/etc/my.cnf": notify => Service[''mysqld''], ensure => present, mode => 644, owner => root, group => root, replace => true, source => [ "puppet:///nodes/$fqdn/my.cnf", "puppet:///modules/mysql/my.cnf" ] } } class mysql-server inherits mysql { package { ''mysql-server'': ensure => present, before => [ File[''/etc/my.cnf''], ], } service { ''mysqld'': ensure => running, enable => true, hasrestart => true, hasstatus => true, } } *Attempts to call mysql-server class in a test node *node ''server.example.com'' { - include mysql-server - include mysql::mysql-server - class {''mysql-server''} - class {''mysql::mysql-server''} } None of the above examples work, and I''m pretty sure I''ve just screwed up how to call the mysql-server module, but I''m out of theories on what I''ve messed up. Anything jump out to anyone? Thanks! ** -- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Kodiak Firesmith
2013-Jan-31 16:15 UTC
[Puppet Users] Re: Calling a "subclass" correctly in a node def?
I figured this out via taking another look at the style guide. This is resolved. Changed this to this: class mysql-server inherits mysql{} ...to... class mysql::server inherits mysql{} And in node def: include mysql::server Worked perfectly. Thanks style guide! *http://docs.puppetlabs.com/guides/style_guide.html#class-inheritance* -- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Keith Burdis
2013-Jan-31 16:18 UTC
Re: [Puppet Users] Re: Calling a "subclass" correctly in a node def?
If you like the style guide the you''ll like puppet-lint - https://github.com/rodjek/puppet-lint - Keith On 31 January 2013 16:15, Kodiak Firesmith <kfiresmith@gmail.com> wrote:> I figured this out via taking another look at the style guide. This is > resolved. > > Changed this to this: > > class mysql-server inherits mysql{} > ...to... > class mysql::server inherits mysql{} > > And in node def: > > include mysql::server > > > Worked perfectly. Thanks style guide! > *http://docs.puppetlabs.com/guides/style_guide.html#class-inheritance* > > -- > 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+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Gary Larizza
2013-Jan-31 16:21 UTC
Re: [Puppet Users] Re: Calling a "subclass" correctly in a node def?
Also, do note that hyphens in class names will cause problems in Puppet --> http://projects.puppetlabs.com/issues/5268 Underscores are preferred for the reasons outlined in the Ticket. On Thu, Jan 31, 2013 at 8:18 AM, Keith Burdis <keith@burdis.org> wrote:> If you like the style guide the you''ll like puppet-lint - > https://github.com/rodjek/puppet-lint > > - Keith > > > On 31 January 2013 16:15, Kodiak Firesmith <kfiresmith@gmail.com> wrote: > >> I figured this out via taking another look at the style guide. This is >> resolved. >> >> Changed this to this: >> >> class mysql-server inherits mysql{} >> ...to... >> class mysql::server inherits mysql{} >> >> And in node def: >> >> include mysql::server >> >> >> Worked perfectly. Thanks style guide! >> *http://docs.puppetlabs.com/guides/style_guide.html#class-inheritance* >> >> -- >> 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+unsubscribe@googlegroups.com. >> To post to this group, send email to puppet-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/puppet-users?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > 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+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Gary Larizza Professional Services Engineer -- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Kodiak Firesmith
2013-Jan-31 17:09 UTC
Re: [Puppet Users] Re: Calling a "subclass" correctly in a node def?
Thanks very much Keith; if it''s nearly as thorough as rpmlint I''ve no doubt it will be illustrative and saddening to run my humble modules through. :) On Thursday, January 31, 2013 11:18:22 AM UTC-5, Keith Burdis wrote:> > If you like the style guide the you''ll like puppet-lint - > https://github.com/rodjek/puppet-lint > > - Keith > > > On 31 January 2013 16:15, Kodiak Firesmith <kfire...@gmail.com<javascript:> > > wrote: > >> I figured this out via taking another look at the style guide. This is >> resolved. >> >> Changed this to this: >> >> class mysql-server inherits mysql{} >> ...to... >> class mysql::server inherits mysql{} >> >> And in node def: >> >> include mysql::server >> >> >> Worked perfectly. Thanks style guide! >> *http://docs.puppetlabs.com/guides/style_guide.html#class-inheritance* >> >> -- >> 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...@googlegroups.com <javascript:>. >> To post to this group, send email to puppet...@googlegroups.com<javascript:> >> . >> Visit this group at http://groups.google.com/group/puppet-users?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > >-- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Kodiak Firesmith
2013-Jan-31 17:10 UTC
Re: [Puppet Users] Re: Calling a "subclass" correctly in a node def?
That''s a great point. Excuse me whilst I go rename a few modules... :/ On Thursday, January 31, 2013 11:21:13 AM UTC-5, Gary Larizza wrote:> > Also, do note that hyphens in class names will cause problems in Puppet > --> http://projects.puppetlabs.com/issues/5268 Underscores are preferred > for the reasons outlined in the Ticket. > > > On Thu, Jan 31, 2013 at 8:18 AM, Keith Burdis <ke...@burdis.org<javascript:> > > wrote: > >> If you like the style guide the you''ll like puppet-lint - >> https://github.com/rodjek/puppet-lint >> >> - Keith >> >> >> On 31 January 2013 16:15, Kodiak Firesmith <kfire...@gmail.com<javascript:> >> > wrote: >> >>> I figured this out via taking another look at the style guide. This is >>> resolved. >>> >>> Changed this to this: >>> >>> class mysql-server inherits mysql{} >>> ...to... >>> class mysql::server inherits mysql{} >>> >>> And in node def: >>> >>> include mysql::server >>> >>> >>> Worked perfectly. Thanks style guide! >>> *http://docs.puppetlabs.com/guides/style_guide.html#class-inheritance* >>> >>> -- >>> 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...@googlegroups.com <javascript:>. >>> To post to this group, send email to puppet...@googlegroups.com<javascript:> >>> . >>> Visit this group at http://groups.google.com/group/puppet-users?hl=en. >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> -- >> 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...@googlegroups.com <javascript:>. >> To post to this group, send email to puppet...@googlegroups.com<javascript:> >> . >> Visit this group at http://groups.google.com/group/puppet-users?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > Gary Larizza > Professional Services Engineer >-- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Keith Burdis
2013-Jan-31 17:16 UTC
Re: [Puppet Users] Re: Calling a "subclass" correctly in a node def?
I certainly found it so :-) On 31 Jan 2013 17:09, "Kodiak Firesmith" <kfiresmith@gmail.com> wrote:> Thanks very much Keith; if it''s nearly as thorough as rpmlint I''ve no > doubt it will be illustrative and saddening to run my humble modules > through. :) > > On Thursday, January 31, 2013 11:18:22 AM UTC-5, Keith Burdis wrote: >> >> If you like the style guide the you''ll like puppet-lint - >> https://github.com/rodjek/**puppet-lint<https://github.com/rodjek/puppet-lint> >> >> - Keith >> >> >> On 31 January 2013 16:15, Kodiak Firesmith <kfire...@gmail.com> wrote: >> >>> I figured this out via taking another look at the style guide. This is >>> resolved. >>> >>> Changed this to this: >>> >>> class mysql-server inherits mysql{} >>> ...to... >>> class mysql::server inherits mysql{} >>> >>> And in node def: >>> >>> include mysql::server >>> >>> >>> Worked perfectly. Thanks style guide! >>> *http://docs.puppetlabs.com/guides/style_guide.html#class-inheritance* >>> >>> -- >>> 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...@**googlegroups.com. >>> To post to this group, send email to puppet...@googlegroups.com. >>> Visit this group at http://groups.google.com/**group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en> >>> . >>> For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>> . >>> >>> >>> >> >> -- > 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+unsubscribe@googlegroups.com. > To post to this group, send email to puppet-users@googlegroups.com. > Visit this group at http://groups.google.com/group/puppet-users?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Kodiak Firesmith
2013-Jan-31 20:27 UTC
Re: [Puppet Users] Re: Calling a "subclass" correctly in a node def?
So I finished the module based on the style guide and have a working parameterized mysql-client/server module. Thanks everyone for the input that helped me get there. # = Class: mysql # # This class installs/configures/manages mysql # # == Parameters: # # mysql_role => mysqlServer # mysql_role => mysqlClient # # == Requires: # # Nothing. # # == Sample Usage: # # class {''mysql'': # mysql_role => mysqlServer, # } # # Main class that will call either mysql::mysqlClient or mysql::mysqlClient, mysql::mysqlServer depending on whether the node is defined as a client or server via $mysql_role class mysql ( $mysql_role ) { case $mysql_role { ''mysqlClient'': { include mysql::mysqlClient } ''mysqlServer'': { include mysql::mysqlClient, mysql::mysqlServer } default: { include mysql::mysqlClient } } } # End of main class # Role-based class ''mysqlClient'' applies no matter what. This installs mysql, and ensures a basic my.cnf file. class mysql::mysqlClient { package { ''mysql'': ensure => present, before => [ File[''/etc/my.cnf''], ], } file { "/etc/my.cnf": ensure => present, mode => 644, owner => root, group => root, replace => true, source => [ "puppet:///nodes/$fqdn/my.cnf", "puppet:///modules/mysql/my.cnf" ], } } # End of mysqlClient # Role-based class ''mysqlServer'' conditionally applies to provide MySQL server role items. class mysql::mysqlServer { package { ''mysql-server'': ensure => present, before => [ File[''/etc/my.cnf''], ], } service { ''mysqld'': ensure => running, enable => true, hasrestart => true, hasstatus => true, subscribe => File[''/etc/my.cnf''], } } On Thursday, January 31, 2013 12:16:11 PM UTC-5, Keith Burdis wrote:> > I certainly found it so :-) > On 31 Jan 2013 17:09, "Kodiak Firesmith" <kfire...@gmail.com <javascript:>> > wrote: > >> Thanks very much Keith; if it''s nearly as thorough as rpmlint I''ve no >> doubt it will be illustrative and saddening to run my humble modules >> through. :) >> >> On Thursday, January 31, 2013 11:18:22 AM UTC-5, Keith Burdis wrote: >>> >>> If you like the style guide the you''ll like puppet-lint - >>> https://github.com/rodjek/**puppet-lint<https://github.com/rodjek/puppet-lint> >>> >>> - Keith >>> >>> >>> On 31 January 2013 16:15, Kodiak Firesmith <kfire...@gmail.com> wrote: >>> >>>> I figured this out via taking another look at the style guide. This is >>>> resolved. >>>> >>>> Changed this to this: >>>> >>>> class mysql-server inherits mysql{} >>>> ...to... >>>> class mysql::server inherits mysql{} >>>> >>>> And in node def: >>>> >>>> include mysql::server >>>> >>>> >>>> Worked perfectly. Thanks style guide! >>>> *http://docs.puppetlabs.com/guides/style_guide.html#class-inheritance* >>>> >>>> -- >>>> 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...@**googlegroups.com. >>>> To post to this group, send email to puppet...@googlegroups.com. >>>> Visit this group at http://groups.google.com/**group/puppet-users?hl=en<http://groups.google.com/group/puppet-users?hl=en> >>>> . >>>> For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>>> . >>>> >>>> >>>> >>> >>> -- >> 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...@googlegroups.com <javascript:>. >> To post to this group, send email to puppet...@googlegroups.com<javascript:> >> . >> Visit this group at http://groups.google.com/group/puppet-users?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> >-- 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+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.