parameters set with array

16 views
Skip to first unread message

OS

unread,
Jul 18, 2014, 2:57:35 AM7/18/14
to puppet...@googlegroups.com
Hello all,

I am newbie to puppet and sorry if it is a silly question. What is wrong with my manifest?

define webapp ($domain,$port){
  file { "/tmp/${name}":                 ------------> This is working and creating the files as /tmp/test , /tmp/test1 etc
    content => "Server:${port}",
  }
  notify { $domain: }
}

$websites = ['test','test1','test2']

webapp { $websites :
  domain => $websites,          ---------> Here, how  can iterate websites array? It gives error as duplicate definition.
  port => 80,
}

Thanks,
OS



David Schmitt

unread,
Jul 21, 2014, 2:33:28 AM7/21/14
to puppet...@googlegroups.com
Do you want to have each of the websites test1 through test3 to be
running on each of the domains test1 through test3, or do you want to
have each website running on its own domain?

In the former case, work with the array of domains with webapp to create
unique resources. E.g by using something like

> https://github.com/DavidS/puppet-common/blob/master/plugins/puppet/parser/functions/prefix_with.rb

In the latter case, remove the $domain argument or default it to $name
and do not pass wrong data to your define.


Other possibilities include custom hiera lookups, and passing domain
data as a hash and indexing by $name.


Regards, D.



Reply all
Reply to author
Forward
0 new messages