Defined resource type examples
Defined resource type definition
Defining a type creates a new defined resource type. The name of this defined
type has two namespace segments, comprising the name of the module
containing the defined type, apache
, and the name of the defined
type itself, vhost
.
define apache::vhost ($port, $docroot, $servername = $title, $vhost_name = '*') { include apache include apache::params $vhost_dir = $apache::params::vhost_dir file { "${vhost_dir}/${servername}.conf": content => template('apache/vhost-default.conf.erb'), owner => 'www', group => 'www', mode => '644', require => Package['httpd'], notify => Service['httpd'], }
For details about defined type usage and syntax, see Defined resource types.
Defined type resource declaration
Declarations of an instance, or resource, of a defined type are similar to other
resource declarations. This example declares a instance of the
apache::vhost
defined type, with a title of "homepages" and the
port
and docroot
attributes specified.
apache::vhost { 'homepages': port => 8081, docroot => '/var/www-testhost', }
For details about defined type usage and syntax, see Defined resource types.
Defined type resource reference
A resource reference to an instance of the apache::vhost
defined
resource. Every namespace segment in a resource reference must be capitalized.
Apache::Vhost['homepages']
For details about defined type usage and syntax, see Defined resource types. For details about resource references, see Resource and class references.