Questions tagged [chef-template]
21 questions
6
votes
2 answers
Chef Ruby loop over attributes in an .erb template file
So this might be a little confusing but bear with me. In short I want to loop over all attributes with a certain key value and then insert them into a template if the values are not empty. Here is my code:
ATTRIBUTES:
# === Default file…

jarsever
- 690
- 1
- 7
- 15
3
votes
2 answers
Combining two templates from two Chef cookbooks
I have a cookbook for installing a base product (Mediaflux), and a second cookbook that tailors it for a particular specialised use-case (DaRIS). The first cookbook's recipe is run to do the "base install" and the second one's recipe is run to…

Stephen C
- 698,415
- 94
- 811
- 1,216
2
votes
1 answer
get calling cookbook within chef custom resource
I have a cookbook my_service with a custom resource write_config.
This resource is called from another cookbook node_a.
my_service/resources/write_config.rb:
property :template_source, String, name_property: true
property :calling_cookbook,…

andiba
- 1,508
- 2
- 11
- 22
1
vote
0 answers
Converting chef upstart template to systemd for ubuntu 16.04
I have one upstart template in chef-Cookbook and want to convert it into Systemd so that it can be supported in 16.04. I have already converted but faced the issue as my server is not starting properly.
Below is the upstart script…

Baloria
- 11
- 1
1
vote
1 answer
Converting chef upstart template to systemd
I have one upstart template in chef-Cookbook and want to convert it into Systemd so that it can be supported in 16.04.
I have already converted but faced the issue as my server is not starting properly.
Below is the upstart script…

Arora20
- 983
- 10
- 17
1
vote
1 answer
Chef ERB template with Logstash Grok pattern issues
I have a logstash config file that I need to convert to a chef erb template (mainly the filters section). However, I keep running into issues due to the format of the grok patterns.
Below is an example of the grok pattern.
grok {
match =>…

Joshua Zitting
- 23
- 2
1
vote
2 answers
is it possible to append a partial template to exsiting file? [chef cookbook]
I'm looking to add configurations to a conf file that is extracted from a tar file.
Currently the cookbook is using a template to overwrite the whole file instead I need to use the original file as a template and add to it.
Partial templates…

david
- 741
- 3
- 10
- 29
0
votes
1 answer
Loop and difference in chef template
{% for peer_ip in all_ips.split(',') | difference([source_ip]) %}
{{ peer_ip }}
{% endfor %}
Where source ip is the ip address of the server where this is run and peer ip is the secondary ip for the same service. all_ips contains 2 ips of…

Aswin
- 19
- 4
0
votes
1 answer
How can I get Chef to error or at least report a missing variable in an .erb template?
If I have a line like the below in an .erb:
TMP_DIR=$(mktemp -d <%= @temp_dir %>/tmp_dir.XXXXXX)
Is there a way I can get Chef to fail, or at least report, if the @temp_dir variable is undefined?
Ideally I'd like to do this with a single…

Andrew Campbell
- 13
- 4
0
votes
1 answer
How to preserve existing host file when running chef template resource
I'm trying to add new set of FQDN and IPs into the existing Windows hosts file by using the Chef template resources. What I found out is when I ran the chef recipe it will erase the existing hosts file and then add the new updates. I only want to…

Fang
- 151
- 1
- 11
0
votes
1 answer
How to use local variable of whitespace array in chef template resource
I am trying to use whitespace arrays in chef template, like below and when I run the chef-client to execute the recipe getting an error saying: option variables must be a kind of [Hash]! below is recipe file
abc = node['abc']
def1 =…

ravi
- 1
- 2
0
votes
1 answer
Chef template render nested object
I am trying to render a yaml object in chef template it is working fine but as we know in yaml spaces also matters so it is creating new properties.
collection: <%= @collection.to_hash.to_yaml %>
Where collection is a json object
collection = {…

9me
- 1,078
- 10
- 36
0
votes
1 answer
Chef Template : Using a nested object to generate a configuration file
I would like to generate a config file from a Chef template. What is the correct syntax for achieving this in Chef 13+
I have a databag with the following sub keys:
"mykey1" : {
"param1" : "mysubvalue1",
"param2" : "mysubvalue2"
},
"mykey2" : {
…

Sam Hammamy
- 10,819
- 10
- 56
- 94
0
votes
1 answer
Chef: 'kitchen converge' not sourcing new template
I've generated a new template which I will be using to edit a Nginx conf file.
The nginx.conf.erb file is created in my cookbook's Templates folder and I have edited it to make it configure Nginx as I want to.
In my recipe, I have then added the…

Stephen Walsh
- 815
- 4
- 18
- 34
0
votes
1 answer
filtering ip in chef
I got a data-center kind of setup at my place. So basically I am creating a logstash conf file where it will use the filter parameter to include the datacenter name
for eg:-
10.21.53.x :- APP1 {10.21.53. belongs to APP1 datacenter and so…

Ashwin
- 2,875
- 1
- 13
- 21