On 09/07/2012 03:20 PM, jcbollinger wrote:

> That's what I addressed at the end of my previous message.  I strongly
> recommend that you look into hiera.  Adding to what I already said,
> however, resources of defined types are just fine when a resource (as
> opposed to a class) is in fact what you want.  It is worthwhile to
> understand the difference between class and resource at the conceptual
> level, because there are some circumstances that require a class.  You
> may save yourself future grief if you start out with classes where
> they're appropriate, even if, for the moment, they're not actually needed.

I don't think you understood me there :) I use hiera for some purposes,
but this is my class:

class cobbler (
  $service_name   = $cobbler::params::service_name,
  $package_name   = $cobbler::params::package_name,
  $package_ensure = $cobbler::params::package_ensure,
  $distro_path    = $cobbler::params::distro_path,
) inherits cobbler::params {
  package { $package_name :
    ensure => $package_ensure,
  }
  service { $service_name :
    ensure  => running,
    enable  => true,
    require => Package[$package_name],
  }
  file { $distro_path :
    ensure => directory,
    owner  => root,
    group  => root,
    mode   => '0755',
  }
  file { '/etc/cobbler/settings':
    ensure  => present,
    owner   => root,
    group   => root,
    mode    => '0644',
    content => template('cobbler/settings.erb'),
    notify  => Service["$service_name"],
  }
  define add_distro ($arch,$isolink){
    $distro = $title
    cobblerdistro { $distro :
      ensure  => present,
      arch    => $arch,
      isolink => $isolink,
      destdir => $cobbler::distro_path,
      require => Service[$cobbler::service_name],
    }
  }
  define del_distro (){
    $distro = $title
    cobblerdistro { $distro :
      ensure  => absent,
      destdir => $cobbler::distro_path,
      require => Service[$cobbler::service_name],
    }
  }
}


So, from node manifest, I can do this:
node 'mynode' {
  class { 'cobbler':
    distro_path => '/data/distro'
  }
  cobbler::add_distro { 'CentOS-6.3-x86_64':
    arch    => 'x86_64',
    isolink =>
'http://mi.mirror.garr.it/mirrors/CentOS/6.3/isos/x86_64/CentOS-6.3-x86_64-bin-DVD1.iso',
  }
  cobbler::add_distro { 'CentOS-6.2-x86_64':
    arch    => 'x86_64',
    isolink =>
'http://mi.mirror.garr.it/mirrors/CentOS/6.2/isos/x86_64/CentOS-6.2-x86_64-bin-DVD1.iso',
  }
}


Is this OK?

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

Reply via email to