Ask Your Question
0

How do I require a specific instance of a class?

asked 2016-03-10 05:25:07 -0500

Tamerz gravatar image

Using the example from the Apache module:

apache::vhost { 'redirect.example.com non-ssl':
  servername      => 'redirect.example.com',
  port            => '80',
  docroot         => '/var/www/redirect',
  redirect_status => 'permanent',
  redirect_dest   => 'https://redirect.example.com/'
}

apache::vhost { 'redirect.example.com ssl':
  servername => 'redirect.example.com',
  port       => '443',
  docroot    => '/var/www/redirect',
  ssl        => true,
}

How can I reference only the "redirect.example.com ssl" instance of the "apache::vhost" instance? I would want to do it something like this:

file['/var/www/redirect/index.html':
  require => Class['apache::vhost'],
}

I'm not sure how to tell it to look at the second vhost and not the first listed one.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-03-10 12:09:06 -0500

lavaman gravatar image

apache::vhost is not a class, it's a defined type. You reference it just as you would any other resource:

file{ '/var/www/redirect/index.html':
  require => Apache::Vhost['redirect.example.com ssl'],
}
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: 2016-03-10 05:25:07 -0500

Seen: 61 times

Last updated: Mar 10 '16