Home Using template to set a variable in chef
Reply: 1

Using template to set a variable in chef

Mr TObOR
1#
Mr TObOR Published in 2018-02-12 17:46:24Z

new to chef and trying to pass a long list of variables to a batch file run. Have thought of writing a list of these in a template and calling the template in the recipe i.e:

options = template "optionstemplate"

How does one set a variable using hashes from a template of in chef? Please do let me know if this is possible of if there is another way to do this.

coderanger
2#
coderanger Reply to 2018-02-12 18:20:22Z

While technically doable, this is very hard and not recommended. You should instead write some Ruby code to generate the options string you need. Maybe something like:

options = ''
node['mythingy']['options'].each do |key, value|
  options << " --#{key}=#{value}"
end
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.294588 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO