# how do I require a call to a define (function) within a class e.g. apache::vhost

So I have created a little module called makesite which handles website deployments, I am trying to make it work on both our development and production servers but the deploy process is slightly different.

In order to get round this I have an if statement to handle additional steps for production, unfortunately this breaks up some chained commands (-> / ~>) so I need to switch this out for a require parameter.

What i'm not entirely clear on is how I do this with defines within classes, so for example if I required the apache class I would do something like this:

file { "/var/www/${site}/app/storage": mode => '0775', recurse => true, require => Class['apache'], }  But how can I require a call to: apache::vhost {$site }


Also, I would appreciate clarification on the terminology i should use here, I get that apache is a class, is vhost a class? or a function, do we call them methods/defines in puppet world?

edit retag close merge delete

Sort by » oldest newest most voted

apache::vhost is what's known as a defined type:

http://docs.puppetlabs.com/learning/d...

Assuming you call the vhost defined type in the same class as the file you reference, you would simply need to use the reference syntax for your defined type:

require => Apache::Vhost[\$site]

more