On 11.02.2011, at 15:42, [email protected] wrote:
> Hi all,
>
> I'm running puppet 0.25.5 and I'm running into an issue with virtual defines
> for setting up my NGinx Vhosts.
>
> The define is as follows:
>
> class nginx{
>
> ...
>
>
> # Setup a resource to create the configuration files
> define nginx_vhost($website_listen_port = "80",$ssl_enabled = "false"){
> $website_hostname = $title
> # Setup the config file with the appropriate name from the template
> file{"/etc/nginx/conf.d/${title}.conf":
> ensure => file,
> content => template("nginx/nginx_vhost.conf.erb")
> }
> if $ssl_enabled != "false" {
> $website_listen_port = "443"
> file{"/etc/nginx/conf.d/${website_hostname}.ssl.conf":
> ensure => file,
> content => template("nginx/nginx_vhost.conf.erb")
> }
> }
> }
>
> ...
>
> }
>
> What I want to be able to do is the following in my classes:
>
> # Set the websites to be hosted on this server as an array
> $websites = ['testing.domain.com','test2.domain.com']
> # realize the websites
> @nginx::nginx_vhost($websites:)
> realize(Nginx::Nginx_vhost[$websites])
>
>
> The issue that I am running into is that I do not appear to be able to set
> the values for website_liste_port or ssl_enabled through using this
> methodology.
>
> Is the a way to pass the domain *and* the values for
> website_listen_port/ssl_enabled to the define at the point of realization?
>
> Thanks,
>
> Matt
Hi,
I would use variables in resources namevar:
define nginx_vhost($website_listen_port = "80",$ssl_enabled = "false"){
$website_hostname = $title
# Setup the config file with the appropriate name from the template
file{"nginx_${title}_${website_listen}":
path => /etc/nginx/conf.d/${title}.conf":
ensure => file,
content => template("nginx/nginx_vhost.conf.erb")
}
(I can not verify atm.)
hth,
Martin
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.