d.ansimov
d.ansimov

Reputation: 2171

Chef paste string in file for each number 1...5

I have a template.

/path/to/script attribute >> /path/to/log

Need to add to a file that string from a template with "attribute" is numers, lets say, from 1 to 5.

/path/to/script 1 >> /path/to/log
/path/to/script 2 >> /path/to/log
/path/to/script 3 >> /path/to/log
/path/to/script 4 >> /path/to/log
/path/to/script 5 >> /path/to/log

How can i do that, comrads?

Thx in advance.

P.S. "attribute" will be an item in data bag.

Upvotes: 0

Views: 85

Answers (1)

coderanger
coderanger

Reputation: 54267

Erb just uses standard Ruby code for loops so:

<%- (1..5).each do |n| -%>
/path/to/script <%= n %> >> /path/to/log
<%- end -%>

Upvotes: 3

Related Questions