I'm sure there's an easy way to do this, however I can't work it out!
I've got a custom fact named "mysql_repl_dbs" and is has the databases
that a host needs to replicate as a comma separated list.
I want my template for my.cnf to add a replicate-do-db= statement for
each of these values, however when ever I try the following:
<% mysql_repl_dbs.split[','].each do | dbname | -%>
replicate-do-db=<%=dbname%>
<% end -%>
I get an error stating that puppet cannot convert a String to an Integer.
There must be a way to do this, but I'm tearing my hair out here!
Thanks in advance,
Matt
> <% mysql_repl_dbs.split[','].each do | dbname | -%>
> replicate-do-db=<%=dbname%>
> <% end -%>
>
> I get an error stating that puppet cannot convert a String to an Integer.
Function calls in Ruby use round parenthesis or none at
all, not square parenthesis. Square parenthesis are used
for indexing. Your code means: call the 'split' method on
mysql_repl_dbs with no parameters, and then index the
result with the string ','. The split method will return
an array of strings (and since you didn't pass any parameters
to split, it will probably only be one element long, that
element being the original string you tried to split). And
arrays can only be indexed by integers.
What you want is "mysql_repl_dbs.split(',').each() do".
/Bellman
Doh!
I knew it would be something obvious.
Thanks
M.
On 6 Sep 2010 20:55, "Thomas Bellman" <bel...@nsc.liu.se> wrote:
li...@truthisfreedom.org.uk wrote:
> <% mysql_repl_dbs.split[','].each do | dbname | -%>
> replicat...
Function calls in Ruby use round parenthesis or none at
all, not square parenthesis. Square parenthesis are used
for indexing. Your code means: call the 'split' method on
mysql_repl_dbs with no parameters, and then index the
result with the string ','. The split method will return
an array of strings (and since you didn't pass any parameters
to split, it will probably only be one element long, that
element being the original string you tried to split). And
arrays can only be indexed by integers.
What you want is "mysql_repl_dbs.split(',').each() do".
/Bellman
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group...