saz / puppet-sudo

Manage sudo with Puppet on Debian-, RedHat- and SUSE-based linux distributions and some BSDs
Other
105 stars 215 forks source link

escape % in users_groups for erb syntax check #136

Closed sknolin closed 7 years ago

sknolin commented 9 years ago

We have pre-receive hooks that check erb syntax, and the % for sudo groups breaks that parser. %% escapes it

jovandeginste commented 9 years ago

I noticed the same, but this can be fixed in the erb syntax checker. This is what I use:

erb -P -x -T '-' $file | ruby -c
-P               ignore lines which start with "%"

The output now becomes:

$ erb -P -x -T '-' users_groups.erb 
#coding:ASCII-8BIT
_erbout = ''; _erbout.concat "# This file is managed by Puppet. All changes will be reverted\n# on the next Puppet run. Avoid making changes here.\n"

 @users.each do |user| 
_erbout.concat(( user ).to_s); _erbout.concat " ALL=(ALL) ALL\n"
;  end 
 @groups.each do |group| 
_erbout.concat "%"; _erbout.concat(( group ).to_s); _erbout.concat " ALL=(ALL) ALL\n"
;  end 
_erbout.force_encoding(__ENCODING__)

Looks perfectly correct?