On Wed, Jul 25, 2012 at 08:47:14AM -0700, Markus Rekkenbeil wrote:
>  Hello,
> 
>  i have a problem in my sudo manifest file, because in the variable $name
>  comes sometimes usernames like user.lastname, but i need for sudo
>  (includedir /etc/sudoers.d/) file names with no dots (like user_lastname).
> 
>  I need a new variable, where is the dots change by underscores.
> 
> 
>  My first try was like this, but it isn't working well.
> 
>  $name_underscore = "`echo $name | sed 's/\./_/g'`"

The variable $name is reserved for use as as the namevar, so you'll have to use 
something else as a variable name.

http://docs.puppetlabs.com/guides/language_guide.html

You could use an inline template to run the substitution via ruby. Example:

$java_home = inline_template('<%= /jre-([0-9])u([0-9]+)/.match(name); p = 
"/opt/jre1." + $1 + ".0_" + $2 %>')

So for you, something like this (warning, untested):

$username_nous = inline_template('<%= username.gsub(/\./, "_") %>')

Also see:

http://www.ruby-doc.org/core-1.8.7/String.html

 
>    file { "/etc/sudoers.d/${name_underscore}":
>      mode => 440,
>      owner => "root",
>      group => "root",
>      content => template("sudo/sudo.erb"),
>      }
> 
>  Please can anyone help me with my problem?
> 
>  Best regards,
> 
>  Markus Rekkenbeil
> 
>    --
>    You received this message because you are subscribed to the Google Groups
>    "Puppet Users" group.
>    To view this discussion on the web visit
>    [1]https://groups.google.com/d/msg/puppet-users/-/5WXIuAeLgmkJ.
>    To post to this group, send email to [email protected].
>    To unsubscribe from this group, send email to
>    [email protected].
>    For more options, visit this group at
>    http://groups.google.com/group/puppet-users?hl=en.
> 
> References
> 
>    Visible links
>    1. https://groups.google.com/d/msg/puppet-users/-/5WXIuAeLgmkJ

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to