FAQ
Hi
i am using puppet 2.7

i want to echo the Fqdn name in a template by using looping through the
hash,

Example, in site.pp i have

$acc_sudo = $mc_servertype ? {
         'system' => [ '%APP *<%= fqdn %>* =/etc/init.d/httpd start,
/etc/init.d/httpd stop,/etc/init.d/httpd restart, /sbin/services httpd
restart' ],
         'db' => [ '%DB <%= fqdn %> =/etc/init.d/oracle start'],
         'app' => ['%APP <%= fqdn %> =/etc/init.d/httpd start,
/etc/init.d/httpd stop,/etc/init.d/httpd restart, /sbin/services httpd
restart' ],

}



and sudo.erb file i have

<% if mc_servertype == "system" %>

<% acc_sudo.each do |sudo| %><%= sudo %><% end %>

<% end %>

problem is, when its generating the sudo file, its writing like this

%APP *<%= fqdn %>*=/etc/init.d/httpd start, /etc/init.d/httpd
stop,/etc/init.d/httpd restart, /sbin/services httpd restart


but i want to make it like this

%APP server1.test.co=/etc/init.d/httpd start, /etc/init.d/httpd
stop,/etc/init.d/httpd restart, /sbin/services httpd restart


what will be the right syntax for it in site.pp ??

please help with this.




--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/3f966768-7c1f-4c24-975f-97d0fdc6a8cb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Jcbollinger at Mar 5, 2014 at 3:03 pm

    On Tuesday, March 4, 2014 3:56:48 PM UTC-6, Virtual_user wrote:

    Hi
    i am using puppet 2.7

    i want to echo the Fqdn name in a template by using looping through the
    hash,

    Example, in site.pp i have

    $acc_sudo = $mc_servertype ? {
    'system' => [ '%APP *<%= fqdn %>* =/etc/init.d/httpd start,
    /etc/init.d/httpd stop,/etc/init.d/httpd restart, /sbin/services httpd
    restart' ],
    'db' => [ '%DB <%= fqdn %> =/etc/init.d/oracle start'],
    'app' => ['%APP <%= fqdn %> =/etc/init.d/httpd start,
    /etc/init.d/httpd stop,/etc/init.d/httpd restart, /sbin/services httpd
    restart' ],

    }
    There is no hash there. You are using a Puppet language feature called a
    "selector" to assign a value to variable $acc_sudo based on the value of
    variable $mc_servertype. (Which value, by the way, is in each case an
    array containing exactly one string. Weird.)



    and sudo.erb file i have

    <% if mc_servertype == "system" %>

    <% acc_sudo.each do |sudo| %><%= sudo %><% end %>

    <% end %>

    problem is, when its generating the sudo file, its writing like this

    %APP *<%= fqdn %>*=/etc/init.d/httpd start, /etc/init.d/httpd
    stop,/etc/init.d/httpd restart, /sbin/services httpd restart
    Of course it does. Each element of variable acc_sudo is a string. Your
    template says to insert that string into the result, not to interpret it as
    another template.


    but i want to make it like this

    %APP server1.test.co=/etc/init.d/httpd start, /etc/init.d/httpd
    stop,/etc/init.d/httpd restart, /sbin/services httpd restart


    what will be the right syntax for it in site.pp ??
    You are making it harder than it needs to be. What you are after can be
    accomplished with ordinary variable interpolation:

    $acc_sudo = $mc_servertype ? {
             'system' => [ "%APP ${fqdn} =/etc/init.d/httpd start,
    /etc/init.d/httpd stop,/etc/init.d/httpd restart, /sbin/services httpd
    restart" ],
             'db' => [ "%DB ${fqdn} =/etc/init.d/oracle start" ],
             'app' => [ "%APP ${fqdn} =/etc/init.d/httpd start,
    /etc/init.d/httpd stop,/etc/init.d/httpd restart, /sbin/services httpd
    restart" ],
    }

    Note there that (1) the variable interpolation is performed when the string
    is initialized, as opposed to when the template is processed, and (2)
    variables are interpolated into double-quoted strings only, not into
    single-quoted strings.


    John

    --
    You received this message because you are subscribed to the Google Groups "Puppet Users" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/7cb1adc5-6e02-43ca-850e-c460fcf1ac11%40googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedMar 4, '14 at 9:56p
activeMar 5, '14 at 3:03p
posts2
users2
websitepuppetlabs.com

2 users in discussion

Virtual_user: 1 post Jcbollinger: 1 post

People

Translate

site design / logo © 2022 Grokbase