Re: [Puppet Users] Re: How to manage many nodes easily?

2011-06-24 Thread flex
What a good solution! Thanks a lot!

2011/6/24 Nan Liu n...@puppetlabs.com

 On Thu, Jun 23, 2011 at 7:43 PM, flex frostyn...@gmail.com wrote:
  er...that's what we use now, but define and external node cannot use
  together, we want to use external node to manage nodes configuration
 easily,
  so that's why i want to change all the define to class

 ENC doesn't support resources, and defines are custom resources,
 however we can still support ENC by defining this in an app class:

 class app { $software ) {
  app::deploy { $software: }
 }

 define app::deploy {
  app:: add { $name:
 path = /var/$name
  }
 }

 node some_system {
  class { app:
 software = ['app1', 'app2', 'app3'],
  }
 }

 ENC support for parametrized class was added in 2.6.5+. If you need to
 pass custom parameters to the resource, use a hash or write a wrapper
 class for create_resource function to handle any complex usage, and
 that function can be backported from 2.7 to 2.6.x.

 Thanks,

 Nan

  2011/6/23 Martin Alfke tux...@gmail.com
 
  On 06/23/2011 11:52 AM, flex wrote:
   But i think class is singletons, means when using class you can not
 get
   more than one copy of the resource, that's the biggest difference
   between class and define.
  
   Your example give a duplicate definition error in my environment.
  
   So is this my fault or there another way?
 
  You are right. Using class does not work here. But you can use a define
  with parameters and call the define with parameters later on:
 
  define application::add ($appname) {
 file { /var/$appname:
 ensure = directory,
 }
  }
 
  node 'node1' {
 application::add { app1: appname = app1 }
 application::add { app3: appname = app3 }
  }
  node 'node2' {
 application::add { app2: appname = app2 }
 application::add { anyname: appname = app4 }
  }
 
  When calling the define you just have to make sure that the give name is
  uniq.
 
 
  
   2011/6/23 Martin Alfke tux...@gmail.com mailto:tux...@gmail.com
  
  
  
   On Jun 23, 7:44 am, Martin Alfke tux...@gmail.com
   mailto:tux...@gmail.com wrote:
On 06/23/2011 04:35 AM, flex wrote:
   
 These is another question, i have many defines which will
 apply
   an
 application to sepcified path, called as:
   
 application::add { app1: path = /var/app1 }
   
 by this i can apply app1 and app2 in node1, app3 and app4 in
   node2, etc.
   
 now, how do i switch this to a class? Need i create a seperate
   class for
 all the apps although the only difference is the path?
   
You can make use of parameterized classes:
   
class application::add($appname) {
path = '/var/${appname}',
...
   
 }
   
Within your node definition you call the class with desired
   parameter:
   
node 'node1' {
class application::add { appname = 'app1' }
class application::add { appname = 'app3' }
   
}
  
   The mentioned usage of parameterized classes in node definition is
   wrong.
   See:
  
  
 http://docs.puppetlabs.com/guides/language_guide.html#parameterised-classes
  
   node 'node1' {
  class { 'application::app': appname = 'app1' }
  class { 'application::add': appname = 'app3' }
   }
  
   
Kind regards,
   
Martin
   
   
   
   
   
   
   
   
   
 2011/6/21 Chris Phillips ch...@untrepid.com
   mailto:ch...@untrepid.com mailto:ch...@untrepid.com
   mailto:ch...@untrepid.com
   
 I would see a principle whereby nodes should not ever be
   defined
 within the manifest code at all. To me the manifests
 should
   be
 written to be very generic, and then use ENC's to modify
   their
 behaviour at a user level. There is still a lot of
   inconsistency
 within Puppet as to how device specific data can be
 obtained
 (extlookup is very useful but rides roughshod over other
 architectural principles) but I try to stick to keeping
 all
 manifests generic. I write manifests to manage a package,
   then
 create a group in dashboard to relate that function to a
   business
 need and then a node into that group.
   
 On 21 June 2011 14:48, Martin Willemsma
   mwillem...@gmail.com mailto:mwillem...@gmail.com
 mailto:mwillem...@gmail.com mailto:mwillem...@gmail.com
 
   wrote:
   
 We use /etc/puppet/node-definitions/*.pp in site.pp
   similar to
 what Carles is saying.
   
 [node-definitions] is a git repo thats being synced on
   both
 puppermasters. This happens on every push to origin
   
 We use the 

Re: [Puppet Users] Re: How to manage many nodes easily?

2011-06-23 Thread flex
But i think class is singletons, means when using class you can not get more
than one copy of the resource, that's the biggest difference between class
and define.

Your example give a duplicate definition error in my environment.

So is this my fault or there another way?

2011/6/23 Martin Alfke tux...@gmail.com



 On Jun 23, 7:44 am, Martin Alfke tux...@gmail.com wrote:
  On 06/23/2011 04:35 AM, flex wrote:
 
   These is another question, i have many defines which will apply an
   application to sepcified path, called as:
 
   application::add { app1: path = /var/app1 }
 
   by this i can apply app1 and app2 in node1, app3 and app4 in node2,
 etc.
 
   now, how do i switch this to a class? Need i create a seperate class
 for
   all the apps although the only difference is the path?
 
  You can make use of parameterized classes:
 
  class application::add($appname) {
  path = '/var/${appname}',
  ...
 
   }
 
  Within your node definition you call the class with desired parameter:
 
  node 'node1' {
  class application::add { appname = 'app1' }
  class application::add { appname = 'app3' }
 
  }

 The mentioned usage of parameterized classes in node definition is
 wrong.
 See:
 http://docs.puppetlabs.com/guides/language_guide.html#parameterised-classes

 node 'node1' {
class { 'application::app': appname = 'app1' }
 class { 'application::add': appname = 'app3' }
 }

 
  Kind regards,
 
  Martin
 
 
 
 
 
 
 
 
 
   2011/6/21 Chris Phillips ch...@untrepid.com mailto:
 ch...@untrepid.com
 
   I would see a principle whereby nodes should not ever be defined
   within the manifest code at all. To me the manifests should be
   written to be very generic, and then use ENC's to modify their
   behaviour at a user level. There is still a lot of inconsistency
   within Puppet as to how device specific data can be obtained
   (extlookup is very useful but rides roughshod over other
   architectural principles) but I try to stick to keeping all
   manifests generic. I write manifests to manage a package, then
   create a group in dashboard to relate that function to a business
   need and then a node into that group.
 
   On 21 June 2011 14:48, Martin Willemsma mwillem...@gmail.com
   mailto:mwillem...@gmail.com wrote:
 
   We use /etc/puppet/node-definitions/*.pp in site.pp similar to
   what Carles is saying.
 
   [node-definitions] is a git repo thats being synced on both
   puppermasters. This happens on every push to origin
 
   We use the 'default' node which does the baseline configuration
   based on a 'role'
 
   In a separate file $fqdn.pp I place the definitions for a node.
 
   Are there more people using this kind of approach?
 
   ---
   Martin
 
   2011/6/21 Carles Amig� carles.am...@softonic.com
   mailto:carles.am...@softonic.com
 
   We had the same problem and we just separated each node (or
   group of nodes) in one file and then we load them using the
   following syntax:
 
  import nodes/*.pp
 
   You could also organize those files in subdirectories if
 you
   like so:
 
  import nodes/*/*.pp
 
   The only problem we've found with this approach is when
   creating new files, puppetmaster takes a while to see
 them.
 
   El 20/06/2011 5:25, flex escribi�:
 
   We have many modules and many nodes, every node may use
   different
   module, so it's very unpleasant to modify the nodes.pp
   Then i saw the external node, but seems it only support
   class and we
   have many defines called in node.pp
 
   So here is my question: Is there another way for us to
   manage so many
   nodes easily or should i change all the defines to
   classes and using
   external nodes?
 
   --
   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
   mailto:puppet-users@googlegroups.com.
   To unsubscribe from this group, send email to
   puppet-users+unsubscribe@__googlegroups.com
   mailto:puppet-users%2bunsubscr...@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
   

Re: [Puppet Users] Re: How to manage many nodes easily?

2011-06-23 Thread Martin Alfke
On 06/23/2011 11:52 AM, flex wrote:
 But i think class is singletons, means when using class you can not get
 more than one copy of the resource, that's the biggest difference
 between class and define.
 
 Your example give a duplicate definition error in my environment.
 
 So is this my fault or there another way?

You are right. Using class does not work here. But you can use a define
with parameters and call the define with parameters later on:

define application::add ($appname) {
file { /var/$appname:
ensure = directory,
}
}

node 'node1' {
application::add { app1: appname = app1 }
application::add { app3: appname = app3 }
}
node 'node2' {
application::add { app2: appname = app2 }
application::add { anyname: appname = app4 }
}

When calling the define you just have to make sure that the give name is
uniq.


 
 2011/6/23 Martin Alfke tux...@gmail.com mailto:tux...@gmail.com
 
 
 
 On Jun 23, 7:44 am, Martin Alfke tux...@gmail.com
 mailto:tux...@gmail.com wrote:
  On 06/23/2011 04:35 AM, flex wrote:
 
   These is another question, i have many defines which will apply an
   application to sepcified path, called as:
 
   application::add { app1: path = /var/app1 }
 
   by this i can apply app1 and app2 in node1, app3 and app4 in
 node2, etc.
 
   now, how do i switch this to a class? Need i create a seperate
 class for
   all the apps although the only difference is the path?
 
  You can make use of parameterized classes:
 
  class application::add($appname) {
  path = '/var/${appname}',
  ...
 
   }
 
  Within your node definition you call the class with desired parameter:
 
  node 'node1' {
  class application::add { appname = 'app1' }
  class application::add { appname = 'app3' }
 
  }
 
 The mentioned usage of parameterized classes in node definition is
 wrong.
 See:
 
 http://docs.puppetlabs.com/guides/language_guide.html#parameterised-classes
 
 node 'node1' {
class { 'application::app': appname = 'app1' }
class { 'application::add': appname = 'app3' }
 }
 
 
  Kind regards,
 
  Martin
 
 
 
 
 
 
 
 
 
   2011/6/21 Chris Phillips ch...@untrepid.com
 mailto:ch...@untrepid.com mailto:ch...@untrepid.com
 mailto:ch...@untrepid.com
 
   I would see a principle whereby nodes should not ever be defined
   within the manifest code at all. To me the manifests should be
   written to be very generic, and then use ENC's to modify their
   behaviour at a user level. There is still a lot of
 inconsistency
   within Puppet as to how device specific data can be obtained
   (extlookup is very useful but rides roughshod over other
   architectural principles) but I try to stick to keeping all
   manifests generic. I write manifests to manage a package, then
   create a group in dashboard to relate that function to a
 business
   need and then a node into that group.
 
   On 21 June 2011 14:48, Martin Willemsma
 mwillem...@gmail.com mailto:mwillem...@gmail.com
   mailto:mwillem...@gmail.com mailto:mwillem...@gmail.com
 wrote:
 
   We use /etc/puppet/node-definitions/*.pp in site.pp
 similar to
   what Carles is saying.
 
   [node-definitions] is a git repo thats being synced on both
   puppermasters. This happens on every push to origin
 
   We use the 'default' node which does the baseline
 configuration
   based on a 'role'
 
   In a separate file $fqdn.pp I place the definitions for
 a node.
 
   Are there more people using this kind of approach?
 
   ---
   Martin
 
   2011/6/21 Carles Amig� carles.am...@softonic.com
 mailto:carles.am...@softonic.com
   mailto:carles.am...@softonic.com
 mailto:carles.am...@softonic.com
 
   We had the same problem and we just separated each
 node (or
   group of nodes) in one file and then we load them
 using the
   following syntax:
 
  import nodes/*.pp
 
   You could also organize those files in
 subdirectories if you
   like so:
 
  import nodes/*/*.pp
 
   The only problem we've found with this approach is when
   creating new files, puppetmaster takes a while to
 see them.
 
   El 20/06/2011 5:25, flex escribi�:
 
   We have many modules and many nodes, every node
 may use
   different

[Puppet Users] Re: How to manage many nodes easily?

2011-06-22 Thread Martin Alfke


On Jun 23, 7:44 am, Martin Alfke tux...@gmail.com wrote:
 On 06/23/2011 04:35 AM, flex wrote:

  These is another question, i have many defines which will apply an
  application to sepcified path, called as:

  application::add { app1: path = /var/app1 }

  by this i can apply app1 and app2 in node1, app3 and app4 in node2, etc.

  now, how do i switch this to a class? Need i create a seperate class for
  all the apps although the only difference is the path?

 You can make use of parameterized classes:

 class application::add($appname) {
         path = '/var/${appname}',
 ...

  }

 Within your node definition you call the class with desired parameter:

 node 'node1' {
         class application::add { appname = 'app1' }
         class application::add { appname = 'app3' }

 }

The mentioned usage of parameterized classes in node definition is
wrong.
See: http://docs.puppetlabs.com/guides/language_guide.html#parameterised-classes

node 'node1' {
class { 'application::app': appname = 'app1' }
class { 'application::add': appname = 'app3' }
}


 Kind regards,

 Martin









  2011/6/21 Chris Phillips ch...@untrepid.com mailto:ch...@untrepid.com

      I would see a principle whereby nodes should not ever be defined
      within the manifest code at all. To me the manifests should be
      written to be very generic, and then use ENC's to modify their
      behaviour at a user level. There is still a lot of inconsistency
      within Puppet as to how device specific data can be obtained
      (extlookup is very useful but rides roughshod over other
      architectural principles) but I try to stick to keeping all
      manifests generic. I write manifests to manage a package, then
      create a group in dashboard to relate that function to a business
      need and then a node into that group.

      On 21 June 2011 14:48, Martin Willemsma mwillem...@gmail.com
      mailto:mwillem...@gmail.com wrote:

          We use /etc/puppet/node-definitions/*.pp in site.pp similar to
          what Carles is saying.

          [node-definitions] is a git repo thats being synced on both
          puppermasters. This happens on every push to origin

          We use the 'default' node which does the baseline configuration
          based on a 'role'

          In a separate file $fqdn.pp I place the definitions for a node.

          Are there more people using this kind of approach?

          ---
          Martin

          2011/6/21 Carles Amig� carles.am...@softonic.com
          mailto:carles.am...@softonic.com

              We had the same problem and we just separated each node (or
              group of nodes) in one file and then we load them using the
              following syntax:

                     import nodes/*.pp

              You could also organize those files in subdirectories if you
              like so:

                     import nodes/*/*.pp

              The only problem we've found with this approach is when
              creating new files, puppetmaster takes a while to see them.

              El 20/06/2011 5:25, flex escribi�:

                  We have many modules and many nodes, every node may use
                  different
                  module, so it's very unpleasant to modify the nodes.pp
                  Then i saw the external node, but seems it only support
                  class and we
                  have many defines called in node.pp

                  So here is my question: Is there another way for us to
                  manage so many
                  nodes easily or should i change all the defines to
                  classes and using
                  external nodes?

              --
              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
              mailto:puppet-users@googlegroups.com.
              To unsubscribe from this group, send email to
              puppet-users+unsubscribe@__googlegroups.com
              mailto:puppet-users%2bunsubscr...@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
          mailto:puppet-users@googlegroups.com.
          To unsubscribe from this group, send email to
          puppet-users+unsubscr...@googlegroups.com
          mailto:puppet-users%2bunsubscr...@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