Questions tagged [chef-attributes]
18 questions
3
votes
2 answers
Referencing attributes from within a Chef recipe
I have an attribute file titled default.rb with a key in it default['current'] that stores a dir in string format. I wanted to use this for the following command to use when it changes directories:
# Run database migrations
execute 'database…

WhyAyala
- 647
- 7
- 29
2
votes
3 answers
Initialize Ruby hash with a constant value
Actually I want to use such constructs in chef attributes, where I initialize a structure with a constant and modify it
init_value = { "a" => { "b" => "c" } }
prepare = init_value
prepare["a"]["x"] = "y"
now init_value also contains ["a"]["x"] =…

ikrabbe
- 1,909
- 12
- 25
1
vote
1 answer
Chef Error while installing multiple packages using custom attributes
I am trying to install multiple packages with Chef's 'package' resource by using custom attributes.
When I try:
package %w(python3 python3-pip) do
action :install
end
The above code works fine for me, but same code is giving error while trying with…

Asim Baig
- 13
- 3
1
vote
1 answer
How can I override an attribute on a node with Chef?
We have a Chef environment setup. Our deployments work fine, with node attributes properly overridden by roles and environments.
In order to test an upcoming change, we want to change a setting on 1 particular node in our deployment. We don't want…

Eric Liprandi
- 5,324
- 2
- 49
- 68
1
vote
1 answer
Is chef_type mandatory for a node?
In a project that uses Chef Server, we are using the following concepts:
node
role
environment
The environment and role json files looks fine (they have chef_type and json_class):
ENV.json
{
"name": "ENV",
"chef_type": "environment",
…

ROMANIA_engineer
- 54,432
- 29
- 203
- 199
1
vote
1 answer
Chef attributes value reuse
Versions :
Server 12
chef client 12.13.37
I have an attribute file with a lot of url references but all to the same server. I'd like to reference a base url to build up the full path. Then if the source server changes I just change the top…

David
- 21
- 3
0
votes
1 answer
pass variables from a chef resouce to other resources in the same chef recipe
I'm new to Chef and Ruby, I'm very confused how to handle variables in Chef, and I am trying to pass a variable [Var] from ruby_block resource to http_request resource and assign the [Var] value to the value in "value":"#{Var}" in the chef recipe…

Sam2022
- 9
- 2
0
votes
1 answer
How to get the attributes from a cookbook added to the runlist of a node?
I have a cookbook mycookbook which is added to the runlist of a node node_address. Now I want to retrieve the attributes of mycookbook in JSON format from the node.
In this case, I have access to the node so I can ssh in that node and run…

blueowl
- 35
- 6
0
votes
1 answer
How do I change an attribute for a policy group without having to re-compile all of the policyfiles?
I am trying to shift from environment files in Chef to using Policyfiles. https://docs.chef.io/policy.html. I really like the concept, especially since you can include a policy from policy into another, but I am trying to understand how do a simple…

scottymarshall
- 1
- 3
0
votes
2 answers
Chef : Define an attribute with the value of another attribute
In my environment file, I have defined an attribute say
['app']['web'] = 'nginx'
and in another environment file
['app']['web'] = 'apache'
My intention is to create a recipe which will run on any environment. Inside the recipe I'm defining one…

Jyothish
- 1,031
- 1
- 9
- 19
0
votes
2 answers
Chef node attribute definition: define a field by reference other field
How can I define a ruby Hash by this way?
default['mgmt']['query'] = {
'default_interval' => {'diff' => 3600, 'snapshot' => 86400 * 7},
'tables' => {
'deb_packages' => default_interval,
'rpm_packages' => default_interval,
…

osexp2000
- 2,910
- 30
- 29
0
votes
1 answer
Chef - Calling host specific environment attributes dynamically
I am new to Chef and Ruby and I have been playing with recipes for just couple of days. Currently I am stuck with one problem which I think is simple but due to lack of proper knowledge I am not able to solve it.
I am going to creste chef recipy…

Grzesiu Kropka PL
- 11
- 1
- 2
0
votes
2 answers
Executing chef cookbook based on dependency
I have two cookbooks:
CookbookA and CookbookB
CookbookB has an attribute (e.g. "include_xyz") defined.
This should be set to "true" if CookbookA has run otherwise it should be set to "false".
How should "include_xyz" definition in…

Haris Farooqui
- 944
- 3
- 12
- 28
0
votes
1 answer
Chef Attributes Structure
I am just trying to understand if there is a difference on how we define the attribute structure in the cookbook's attribute files.
Following are two examples:
// style-A
default['my_cookbook']['name'] = 'something'
default['my_cookbook']['version']…

jssnirmal
- 78
- 4
0
votes
1 answer
Error while loading Chef data bag item, created via Chef code
I've two questions associated with the issue. (Resolved issue, solution provided below)
I'm having a data bag named, java. It contains the data bag item specific to each node's hostname, as shown below
id: node_hostname
java_config:
…

Saravanan G
- 581
- 1
- 9
- 26