Package requiring a class

30 views
Skip to first unread message

kai

unread,
Mar 11, 2014, 9:13:34 AM3/11/14
to puppet...@googlegroups.com
I have the following two resources defined in a class:

class openvz::install {
$openvz_repo_key = hiera('openvz_repo_key')
$openvz_repo = hiera('openvz_repo')
$openvz_kernel_image = hiera('openvz_kernel_image')
$openvz_kernel_headers = hiera('openvz_kernel_headers')

apt::source { "openvz":
    location => "$openvz_repo",
    release => "wheezy",
    repos => "main",
    http_key => "$openvz_repo_key",
    http_key_server => "$openvz_repo"
  }

  package {
    'libvirt-bin': ensure => present;
    'vzctl': ensure => present;
  }

}

where apt:source is an external class in a module. In most cases the package resource will run before the apt::source, causing it to fail as the apt repo is not there yet. 
How can I make the package resource dependent on the apt::source ? I am assuming using the "require" attribute, but in this case I am not quite sure what the best practice might be. All suggestions are highly appreciated.

Craig Dunn

unread,
Mar 11, 2014, 9:39:39 AM3/11/14
to puppet...@googlegroups.com

Just to clarify, apt::source is a defined resource type, not a class.  Defined resource types can be required like any other resource, for example

package { [ 'libvirt-bin', 'vzctl' ]:
  ensure => present,
  require => Apt::Source['openvz'],
}




--
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 view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/d3f57517-c5d8-424a-b1cc-479876e55804%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Enviatics | Automation and configuration management
http://www.enviatics.com | @Enviatics
Puppet Training http://www.enviatics.com/training/

kai

unread,
Mar 11, 2014, 10:25:45 AM3/11/14
to puppet...@googlegroups.com
Nice, thanks!
Reply all
Reply to author
Forward
0 new messages