FAQ
Hi All,

I am new to puppet template and need your help to update the different
cluster name to elasticsearch.erb based on the environments
(QA,staging,prod)

init.pp

$QA = xyz.test.com,abc.test.com,zbc.test.com
$staging = xyz.stg.com, abc.stg.com,zbc.stg.com
$prod = xyz.prd.com,abc.prd.com,zbc.prd.com`

elasticsearch.yml.erb:

node.name: <%= fqdn %>
network.bind_host: <%= @ipaddress %>
network.publish_host: <%= @ipaddress %>
network.host: <%= @ipaddress %>
*cluster name: *

is if statement can do this ? like clustername : <%if fqdn == $qa then
elastic-qa-cluster?

Appreciate all your help

--
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/42482304-87ef-4439-8a74-e93660d02a70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Rich Burroughs at Aug 30, 2015 at 8:27 pm
    You can do if statements in ERB templates. I've never tried to do exactly
    what you're doing though and I'm not sure if that's the right syntax.

    But I think the way people usually would deal with this sort of thing is
    with Hiera. Are you using it? You could set a custom fact on your hosts
    that would tell whether they are QA, staging or Prod. And then have those
    different values in the Hiera data.

    You will probably run into more environment specific data like this and
    Hiera is a good way to handle it.


    Rich
    On Sun, Aug 30, 2015 at 1:09 PM miki wrote:

    Hi All,

    I am new to puppet template and need your help to update the different
    cluster name to elasticsearch.erb based on the environments
    (QA,staging,prod)

    init.pp

    $QA = xyz.test.com,abc.test.com,zbc.test.com
    $staging = xyz.stg.com, abc.stg.com,zbc.stg.com
    $prod = xyz.prd.com,abc.prd.com,zbc.prd.com`

    elasticsearch.yml.erb:

    node.name: <%= fqdn %>
    network.bind_host: <%= @ipaddress %>
    network.publish_host: <%= @ipaddress %>
    network.host: <%= @ipaddress %>
    *cluster name: *

    is if statement can do this ? like clustername : <%if fqdn == $qa then
    elastic-qa-cluster?

    Appreciate all your help

    --
    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/42482304-87ef-4439-8a74-e93660d02a70%40googlegroups.com
    <https://groups.google.com/d/msgid/puppet-users/42482304-87ef-4439-8a74-e93660d02a70%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
    --
    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/CAPGcbtBWs95UM6O107GtirhkkKQ3JQ68eZsmRwdMb%3DCp1Zidpw%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Jcbollinger at Aug 31, 2015 at 1:21 pm

    On Sunday, August 30, 2015 at 3:09:15 PM UTC-5, miki wrote:
    Hi All,

    I am new to puppet template and need your help to update the different
    cluster name to elasticsearch.erb based on the environments
    (QA,staging,prod)

    init.pp

    $QA = xyz.test.com,abc.test.com,zbc.test.com
    $staging = xyz.stg.com, abc.stg.com,zbc.stg.com
    $prod = xyz.prd.com,abc.prd.com,zbc.prd.com`

    elasticsearch.yml.erb:

    node.name: <%= fqdn %>
    network.bind_host: <%= @ipaddress %>
    network.publish_host: <%= @ipaddress %>
    network.host: <%= @ipaddress %>
    *cluster name: *

    is if statement can do this ? like clustername : <%if fqdn == $qa then
    elastic-qa-cluster?
    It's not clear what the "this" is that you want to do. The fragment you
    posted is not valid ERB, and it is problematic. The key to writing ERB
    templates is to recognize that what you are actually writing is ordinary
    Ruby code, but presented inside-out:

        - Each span of text outside a scriptlet (<%[=]...%>) can be thought of
        as being a string argument to a 'print' call.
        - Each expression scriptlet (<%= ... %>) can be thought of as providing
        a 'print' argument as a Ruby expression (the value of the expression within
        is printed to the output)
        - Each command scriptlet <% ... %> provides ordinary Ruby code to appear
        between the 'print' statements implied by the other template elements; the
        value produced by executing that code is not emitted into the template
        output.

    Template output can certainly be conditional. Here are two ways to do it:

    Using an expression scriptlet:

    cluster.name: <%= (fqdn == @qa) ? 'elastic-qa-cluster' : 'other-cluster' %>


    Using command scriptlets:

    cluster.name: <% if fqdn == @qa { %>elastic-qa-cluster<% } else { %>other-
    cluster<% }%>


    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/8cc0e7f6-8178-445e-9bf2-9194d219d598%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedAug 30, '15 at 8:09p
activeAug 31, '15 at 1:21p
posts3
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase