file: square bracket in template

240 views
Skip to first unread message

Laurent CREPET

unread,
Apr 16, 2014, 9:01:13 AM4/16/14
to puppet...@googlegroups.com
Hi,

I'm new to Puppet. I'm using Puppet 3.4.3. I'm trying tried to build a template of file /etc/my.cnf. Puppet does not like the square brackets in my.cnf.erb, giving the following error:
    Error: Parameter source failed on File[/etc/my.cnf]: Could not understand source [mysqld]

I will have a look at the Puppet Forge for modules to deal with MySQL. However, can we have a square bracket in a template (outside of the "Out-of-Scope Variables" use) ?

Regards,
Laurent.

jcbollinger

unread,
Apr 16, 2014, 1:42:40 PM4/16/14
to puppet...@googlegroups.com


To the best of my knowledge, square brackets appearing in ERB template text have no special meaning to ERB.  They are just copied verbatim to the output.

I suspect that you have written something like

file { '/etc/my.cnf'':
  source => template('my.cnf.erb')
}

where what you want is

file { '/etc/my.cnf'':
  content => template('my.cnf.erb')
}

The distinction is quite important: the 'source' parameter is expected to specify a URL from which the agent get retrieve the desired file content, whereas the 'content' property gives the content itself.  (The two are mutually exclusive.)


John

Laurent CREPET

unread,
Apr 17, 2014, 10:06:32 AM4/17/14
to puppet...@googlegroups.com


Le mercredi 16 avril 2014 19:42:40 UTC+2, jcbollinger a écrit :

To the best of my knowledge, square brackets appearing in ERB template text have no special meaning to ERB.  They are just copied verbatim to the output.

I suspect that you have written something like

file { '/etc/my.cnf'':
  source => template('my.cnf.erb')
}

where what you want is

file { '/etc/my.cnf'':
  content => template('my.cnf.erb')
}

The distinction is quite important: the 'source' parameter is expected to specify a URL from which the agent get retrieve the desired file content, whereas the 'content' property gives the content itself.  (The two are mutually exclusive.)



You're right about the fact that I've used "source" instead of "content" !
Thanks for your help.
 
Reply all
Reply to author
Forward
0 new messages