[chef] Re: Looping in chef


Chronological Thread 
  • From: Peter Norton < >
  • To: " " < >
  • Subject: [chef] Re: Looping in chef
  • Date: Mon, 4 Nov 2013 13:37:10 -0500

It's pretty common to pass in the hash from the databag and unpack it in the erb template, something like this (which is creating a key=value java properties file, but the idea is the same):

<% @properties.each do | prop| p prop%>
<%= prop["property"].strip %>=<%= prop["value"].strip %>
<% end %>

-Peter




On Mon, Nov 4, 2013 at 1:21 PM, Guy Matz < " target="_blank"> > wrote:
Ladles & Jellyspoons,
Hello!  I have to create a password file for proftpd and am feeling ambivalent about how to go about it, was hoping someone might help . . .

Proftpd needs to have an olde style passwd file (hashed/crypted passwords included) to authenticate against.  I am currently getting the usernames & passwords from a data bag and looping through them, checking my password file to see if they exist and adding if they don't.  A helper method within a library file is actually doing the work, and I'm wondering if rather than passing the users to the method one-by-one, if I could be passing the entire data structure . . .  it doesn't sound like a big difference, but passing the entire struct back to the helper would make things a log easier.  It doesn't seem like the chef way, though.  But I'm very new to the chef way.

Puppet had a prased_file provider that made this sort of thing easier, but this doesn't seem to exist in chef.

Any thoughts would be appreciated.

Thanks,
Guy






Archive powered by MHonArc 2.6.16.

§