Ask Your Question

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

asked 2014-07-31 12:27:25 -0600

dwdwdwdwdw gravatar image

updated 2014-07-31 19:57:07 -0600

ramindk gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-07-31 19:51:29 -0600

lavaman gravatar image

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

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]

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


Asked: 2014-07-31 12:25:16 -0600

Seen: 1,580 times

Last updated: Jul 31 '14