Questions tagged [chef-template]

21 questions
0
votes
1 answer

How to put a if statement inside a loop within a chef template file?

This works great without the if statement but not sure what the best way to use the if is ? <% node['some-node']['datasource'].each do |dbname,values| -%> <%= if (dbname.to_s != 'ReferenceData') -%>
user2062360
  • 1,323
  • 5
  • 16
  • 29
0
votes
1 answer

Chef - repeat block of text in template x times

Is there any way to repeat same text block in template X times? For example, I need to generate template with hosts names and a block of text. Host1 A lot of text . . HostX A lot of text
Igor Zilberman
  • 1,048
  • 1
  • 11
  • 16
0
votes
2 answers

How does Chef include files generated on runtime as a template source

Using Chef recipe, I am first generating a .erb file dynamically based on inputs from a CSV file and then I want to use that .erb file as a template source. But unfortunately the changes made (in .erb file) are not considered while the recipe is…
0
votes
1 answer

How to write a template to automatically write "server.x=hostname:Quorom_Port:Election_Port" in zoo.cfg

I want "server.x=hostname:Quorom_Port:Election_Port" value to be be written to zoo.cfg using a template based on number hosts declared in attributes/default.rb file default['zookeeper']['servers'] = ["hostname1", "hostname2",…
Shaik Sadiq Ahmed
  • 173
  • 1
  • 4
  • 18
0
votes
1 answer

how to use a 'not_if' condition on a template resource

I'm trying to use a 'not_if' condition in a template resource as showcased by docs.chef.io template "/tmp/somefile" do mode '0644' source "somefile.erb" not_if { node[:some_value] } end I'm new to chef and I'm unsure how to proceed to create…
david
  • 741
  • 3
  • 10
  • 29
0
votes
1 answer

Chef::Mixin::Template::TemplateError (can't convert Symbol into Integer)

I'm trying to use the below set attribute values from attribute file to comapany_name.properties.erb file. But the values are not passed. webapp/attributes/default.rb file default['webapp']['company_name']['task_server'] =…
Shaik Sadiq Ahmed
  • 173
  • 1
  • 4
  • 18
1
2