Hi everyone, i''m trying to apply the fully qualified variables aspect in my puppet code and one of variables i use is an array in template file i wrote the following : MONGO_DATABASE_NAME > ''<%=scope.lookupvar(''class_name::params::mongodb_dbname'')%>''> <% if has_variable?(scope.lookupvar(''class_name::params::replicas'')) then > %> > connect(MONGO_DATABASE_NAME, > host=''mongodb://<%=scope.lookupvar(''class_name::params::replicas'').join(",")%>'', > username=''<%=scope.lookupvar(''class_name::params::mongodb_username'')%>'', > password=''<%=scope.lookupvar(''class_name::params::mongodb_password'')%>'') > <% else %> > connect(MONGO_DATABASE_NAME, > host=''<%=scope.lookupvar(''class_name::params::dbhost'')%>'', > username=''<%=scope.lookupvar(''class_name::params::mongodb_username'')%>'', > password=''<%=scope.lookupvar(''class_name::params::mongodb_password'')%>'') > <% end %> >that works fine for both username and password but in case of $replicas OR even $dbhost it doesn''t work as expected snippet from params.pp : $replicas = $mongodb_replicas>>$dbhost = $mongodb ? {> '''' => "$::ec2_local_hostname", > default => "$mongodb" > } >and $mongodb_replicas is defined in nodes.pp for the time being but after deployment the output line was : connect(MONGO_DATABASE_NAME, host='''', username=''correct_username'',> password=''correct_password'') >any idea what''s wrong with these lines Thanks in advance -- Best Regards, Eslam Mamdouh El Husseiny *Systems Administrator** Cloud Niners Ltd. * *Cellular: (+2) 011 198 40 40 Mansoura: (+2) 050 234 70 81 Cairo: (+2) 022 *268 34 60 Fax: (+2) 022 268 34 63 -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
$replicas works now by replacing <% if has_variable?(scope.lookupvar(''class_name::params::replicas'')) then %> with> <% if has_variable?("class_name::params::replicas") then %>but the problem now with $dbhost variable "else condition" i got that error after defining $mongodb variable instead of mongodb_replicas in nodes.pp> undefined method `join'' for :undef:Symbolany ideas ? On Sun, Mar 4, 2012 at 12:30 PM, Eslam Mamdouh <emamdouh@cloud9ers.com>wrote:> Hi everyone, > i''m trying to apply the fully qualified variables aspect in my puppet code > and one of variables i use is an array > > in template file i wrote the following : > > MONGO_DATABASE_NAME >> ''<%=scope.lookupvar(''class_name::params::mongodb_dbname'')%>'' >> <% if has_variable?(scope.lookupvar(''class_name::params::replicas'')) then >> %> >> connect(MONGO_DATABASE_NAME, >> host=''mongodb://<%=scope.lookupvar(''class_name::params::replicas'').join(",")%>'', >> username=''<%=scope.lookupvar(''class_name::params::mongodb_username'')%>'', >> password=''<%=scope.lookupvar(''class_name::params::mongodb_password'')%>'') >> <% else %> >> connect(MONGO_DATABASE_NAME, >> host=''<%=scope.lookupvar(''class_name::params::dbhost'')%>'', >> username=''<%=scope.lookupvar(''class_name::params::mongodb_username'')%>'', >> password=''<%=scope.lookupvar(''class_name::params::mongodb_password'')%>'') >> <% end %> >> > > that works fine for both username and password but in case of $replicas > OR even $dbhost it doesn''t work as expected > > snippet from params.pp : > > $replicas = $mongodb_replicas >> > >> > $dbhost = $mongodb ? { >> '''' => "$::ec2_local_hostname", >> default => "$mongodb" >> } >> > > and $mongodb_replicas is defined in nodes.pp for the time being > > but after deployment the output line was : > > connect(MONGO_DATABASE_NAME, host='''', username=''correct_username'', >> password=''correct_password'') >> > > any idea what''s wrong with these lines > > Thanks in advance > > -- > Best Regards, > Eslam Mamdouh El Husseiny > *Systems Administrator** > Cloud Niners Ltd. > > * > *Cellular: (+2) 011 198 40 40 > Mansoura: (+2) 050 234 70 81 > Cairo: (+2) 022 *268 34 60 > Fax: (+2) 022 268 34 63 > > > >-- Best Regards, Eslam Mamdouh El Husseiny *Systems Administrator** Cloud Niners Ltd. * *Cellular: (+2) 011 198 40 40 Mansoura: (+2) 050 234 70 81 Cairo: (+2) 022 *268 34 60 Fax: (+2) 022 268 34 63 -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Mar 4, 4:47 am, Eslam Mamdouh <emamd...@cloud9ers.com> wrote:> $replicas works now by replacing > > <% if has_variable?(scope.lookupvar(''class_name::params::replicas'')) then %> > > with > > > <% if has_variable?("class_name::params::replicas") then %> > > but the problem now with $dbhost variable "else condition" > i got that error after defining $mongodb variable instead of > mongodb_replicas in nodes.pp > > > undefined method `join'' for :undef:Symbol > > any ideas ?As far as I can tell, nothing in your else block invokes a ''join'' method, so I have to assume that either you have mischaracterized the error case or you have not shown the real template code. We will be able to help you better if you reduce the problem to a simpler test case, and present not only the template code but also all the relevant classes. A one-line template and a five-line class would be sufficient to test join()ing a host array in a template. 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. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.