Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 944847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:39:40+00:00 2026-05-15T22:39:40+00:00

I am using Puppet for automating configuration management across hosts. It can use erb

  • 0

I am using Puppet for automating configuration management across hosts.

It can use erb templates to set up configuration files of various services like apache, postfix etc. across different hosts

Till now we were using shell scripts full of sed, awk, grep filters and such, and now I need to port that code to ruby erb templates.

Let’s get to the coding part:

<%# domain gets its value from Facter, lets assume it to be abc.def.com
x,y,z=<%= domain.split(".").join(",")%>

<%# x,y and z get the values abc,def,com respectively, right ?

So, now I need to know about a bunch of things. First, how can I refer to x, y and z in the rest of the template ?

 <%# these don't work:
    major = <%= x %>
    minor= <%= y %>
    major = #{x}
    minor=$x

Secondly, how do I append a string like “dc=” before each of the split values returned ?

<%# I need something like this (yup, guessed it right, I am trying to generate slapd.conf      
dc=abc,dc=def,dc=com

Alright, so I am not looking for exact answers here, but if someone could tell me at least where to begin learning about these things, that would be great. Thing is, I need to get this done soon, so that work with Puppet isn’t stalled at office. Having said that though, of course, I am ready to give time to learning this, just need to know the exact resources (books/tutorials etc) to start with. Cheers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:39:41+00:00Added an answer on May 15, 2026 at 10:39 pm

    Just remember that the <% gets your straight into Ruby. So the code would not be major = <%=x%> within a <% but just major = x.

    As for the dc code, this wouldn’t be the tightest code, but I don’t play code golf:

      "a.b.c".split('.').collect {|thing| "dc=#{thing}" }.join(',')
    

    irb is your friend. Also I recommend reading at least these — http://ruby-doc.org/core/classes/Array.html, http://ruby-doc.org/core/classes/Hash.html — which are a lot more fun than reading the API docs in any other language I’ve seen.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.