I''m attempting to use puppet for customing the root gecos field to use a template to insert the local hostname for Redhat 5.5 and Solaris 10. I''m using Puppet 2.6.4 with environments and modules and seeing trouble that looks like end of lines not being suppressed from the template. class passwd { user { "root": ensure => present, comment => template("passwd/passwd.root.user.erb"), } passwd.root.user.erb contains: Root user on <%= hostname %> I get the following when I try to run on my clients: Redhat 5.5: err: /Stage[main]/Passwd/User[root]/comment: change from Root user on brm-ut-linclient-1 to "Root user on brm-ut-linclient-1 " failed: Could not set comment on user[root]: Execution of ''/usr/sbin/ usermod -c "Root user on brm-ut-linclient-1 " root'' returned 3: usermod: invalid field ''"Root user on brm-ut- linclient-1 " Solaris 10: err: /Stage[main]/Passwd/User[root]/comment: change from SunOS Super- User on brm-ut-sol10client-1 to "Root user on brm-ut-sol10client-1 " failed: Could not set comment on user[root]: Execution of ''/usr/sbin/ usermod -c "Root user on brm-ut-sol10client-1 " root'' returned 2: UX: /usr/sbin/usermod: ERROR: Invalid syntax. usage: usermod -u uid [-o] | -g group | -G group[[,group]...] | -d dir [-m] | -s shell | -c comment | -l new_logname | -f inactive | -e expire | -A authorization [, authorization ...] | -K key=value ... | -P profile [, profile ...] | -R role [, role ...] login -- So it looks like the newlines are breaking these - is there a way to suppress them or a better way to templatize this? We''re fairly new to puppet... Thanks, Vince -- 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 Mon, Mar 14, 2011 at 11:07 AM, VinceT <vgtaluskie@gmail.com> wrote:> I''m attempting to use puppet for customing the root gecos field to use > a template to insert the local hostname for Redhat 5.5 and Solaris > 10. I''m using Puppet 2.6.4 with environments and modules and seeing > trouble that looks like end of lines not being suppressed from the > template.Adding a hyphen to the closing %> is the way to suppress newlines in ERB templates. <%= hostname -%> -- 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 Mon, Mar 14, 2011 at 11:07 AM, VinceT <vgtaluskie@gmail.com> wrote:> > > class passwd { > > user { "root": > ensure => present, > comment => template("passwd/passwd.root.user.erb"), > > } > > passwd.root.user.erb contains: > > Root user on <%= hostname %> > >For such a simple substitution, you''re working too hard: user { "root": ensure => present, comment => "Root user on ${hostname}"; } Nigel''s comment is spot-on, though: use <%= blah -%> to suppress the trailing newline. If you are planning on doing much templating, you would be well advised to read the ruby docs on ERB as they are the most complete. -- 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 03/15/2011 02:42 AM, Nigel Kersten wrote:> On Mon, Mar 14, 2011 at 11:07 AM, VinceT <vgtaluskie@gmail.com> wrote: >> I''m attempting to use puppet for customing the root gecos field to use >> a template to insert the local hostname for Redhat 5.5 and Solaris >> 10. I''m using Puppet 2.6.4 with environments and modules and seeing >> trouble that looks like end of lines not being suppressed from the >> template. > > > Adding a hyphen to the closing %> is the way to suppress newlines in > ERB templates. > > <%= hostname -%>Alternatively, just make sure there is in fact no linebreak at the end of the template. If you *do* indeed need ERB syntax (when doing something more than just including the value of a fact in a string, such as joining the fields of an array to a new string), you may want to look at the inline_template function for an easier alternative. Creating files w/o newline at EOF is a pain in the neck. HTH, Felix -- 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.