Ask Your Question
1

How can I override resources attributes when splitting files?

asked 2013-05-30 10:52:24 -0500

Ars gravatar image

I have been using the pattern in Pro Puppet of splitting classes into multiple files and including them as one, such as:

::::::::::::::
init.pp
::::::::::::::
class ssh {
    include ssh::params, ssh::install, ssh::config, ssh::service
}
::::::::::::::
params.pp
::::::::::::::
class ssh::params {
  case $operatingsystem {
    'aix': {
      $ssh_package_name = "openssh.base.server"
      $ssh_service_name = "sshd"
      $sshd_config_file = "/etc/ssh/sshd_config"
    }
    'redhat': {
      $ssh_package_name = "openssh-server"
      $ssh_service_name = "sshd"
      $sshd_config_file = "/etc/ssh/sshd_config"
    }
    default: {
    }
  }

  if ($ipaddress_eth1 != "") {
    $listenaddress = $ipaddress_eth1
  }
  else {
    $listenaddress = $ipaddress_eth0
  }
}
::::::::::::::
install.pp
::::::::::::::
class ssh::install {
    package { $ssh::params::ssh_package_name:
        ensure => installed,
    }
}
::::::::::::::
config.pp
::::::::::::::
class ssh::config {
  $listenaddress = $ssh::params::listenaddress
  file { $ssh::params::sshd_config_file:
    ensure => present,
    owner => 'root',
    group => 'root ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-05-30 11:32:30 -0500

llowder gravatar image

For this, you will need to use parametrized classes, and if you are on Puppet 3, I would STRONGLY recommend that you also use hiera so you can take advantage of data binding.

With this, you can setup your hierarchy however makes sense for your organization, then just provide different values in your yaml files (assuming you are only using the default yaml backend).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-05-30 10:52:24 -0500

Seen: 173 times

Last updated: May 30 '13