On 18-11-11 15:58, Peter Horvath wrote: > Seems i dont understand how get over this. > I have this defined resource type > > vhost.pp > > define vhost ($docroot = "/var/www", $servername = > "${hostname}.${domain}", $serveralias = "www.${hostname}.${domain}", > $inorout = "1") { > file{ 'conf':
So, if you use this define twice, you would end up with two File resources named 'conf'... > path => > "/etc/apache2/sites-available/${servername}", > ensure => present, > content => > template('/etc/puppet/modules/apache2/templates/vhost.erb'), > } > > file{ 'link': So, if you use this define twice, you would end up with two File resources named 'link'... Etcetera. You have to make sure that your resource names are globally unique. Why not just do: file { "/etc/apache2/sites-enabled/${servername}": ... } That would solve most of your problems, but keep on reading... > path => "/etc/apache2/sites-enabled/${servername}", > ensure => link, > target => > "/etc/apache2/sites-available/${servername}", > require => File['conf'], > } > > file{ "${docroot}": > ensure => directory, > } If you do this, you have to make sure your $docroot is different for each vhost. > > file{ "${docroot}/${servername}": > ensure => directory, > require => File["${docroot}"], > } > > file{ "${docroot}/${servername}/html/": > ensure => directory, > require => File["${docroot}/${servername}"], > } > > file{ 'defrem': > path => '/etc/apache2/sites-enabled/000-default', > ensure => absent, > } This resource doesn't contain any variable components at all, so this will always result in a duplicate definition. To fix this, you have to do what John Bollinger explained: move this resource outside the defined type. You can either make it virtual and realize() it here, or you can move it to a dedicated class and include the class here. Both methods will work, but I think that current best practices prefer the virual resource over the class inclusion. > > file{ 'index': > path => "${docroot}/${servername}/html/index.html", > ensure => present, > content => "Welcome to hell of ${servername}!!!!", > } > > service{ 'apache2': > ensure => running, > restart => 'service apache2 reload', > require => [ File['conf'], File['link'], > File["${docroot}/${servername}/html/"] ], > subscribe => [ File['conf'], File['defrem'] ], > } > } > > and this is my node config > > node eurwebtest02 { > include apache2 > include apache2::mods > include apache2::pringo > import "apache2/vhost.pp" > > vhost { 'local': > } > > vhost { 'test': > servername => "test.${domain}", > serveralias => "www.test.${domain}", > inorout => '0', > } > } > > > I tried to virtualize vhost in vhost.pp with @ > and realize them in the node config, but seems i cant get a working > solution to use vhost resource type more than 1. > > Can you point me to the right direction? How can i create 100 vhost with > that defined class or something like this Best regards, Martijn Grendelman > > On 18 November 2011 11:19, Peter Horvath <peter.horvat...@gmail.com > <mailto:peter.horvat...@gmail.com>> wrote: > > As i figured out the source of my problem was that i used the defined > resource type twice in a manifest. > I didn't know that a defined resource type cannot be used twice in the > same manifest as you can use multiple times a built in one. > > hmmm > > > On 17 November 2011 22:14, jcbollinger <john.bollin...@stjude.org > <mailto:john.bollin...@stjude.org>> wrote: > > > > On Nov 17, 1:50 pm, Peter Horvath <peter.horvat...@gmail.com > <mailto:peter.horvat...@gmail.com>> wrote: > > i know all of this and i did grep before i wrote this email :) > > There is no other file[conf] > > > In that case, the one declaration must be processed twice. It must > appear inside a defined type that you instantiate more than once. > > If both definition instances are supposed to declare the same file, > then move the declaration outside the definition, make it virtual, and > have the definition 'realize' it instead of declaring it. If the > definitions are each supposed to delare a different file then you have > a bug in your manifest. With respect to the latter possibility, I > observe that the resource title is not an absolute path. That could > be a sign that a variable in the Files' titles was unexpectedly > undefined, but even if not, it's unlikely to be what you want. > > > John > > -- > You received this message because you are subscribed to the Google > Groups "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com > <mailto:puppet-users@googlegroups.com>. > To unsubscribe from this group, send email to > puppet-users+unsubscr...@googlegroups.com > <mailto:puppet-users%2bunsubscr...@googlegroups.com>. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > > > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.