A cookbook is the fundamental unit of configuration and policy distribution in Chef.
Questions tagged [cookbook]
510 questions
0
votes
1 answer
Can I set roles path for knife?
When I run this command from inside a cookbook's directory on my Chef workstation I get an error:
knife list roles/
ERROR: roles: No such file or directory
I need to cd back up to the root of the chef directory and run the command for it to…

red888
- 27,709
- 55
- 204
- 392
0
votes
2 answers
knife add role to node only if role exists
I don't like the default behavior of this command:
knife node run_list add myserver '"role[THISISATEST]"'
It adds THIISATEST even if the role doesn't exists. Is there a switch or argument that will prevent knife from adding a role/recipe to a node…

red888
- 27,709
- 55
- 204
- 392
0
votes
3 answers
How many cookbook versions is safe to store on chef server
As I keep uploading updated versions of my cookbooks to chef server I have to wonder if there is a limit to the number of versions of a cookbook chef server can store.
Is this something I should even be concerned about or is it a none issue? Disk…

red888
- 27,709
- 55
- 204
- 392
0
votes
2 answers
How do i define variable within a template cookbook
I am trying to edit the existing user_management cookbook on the supermarket to include sudoers. I seem to be having problems properly defining the sudoers_groups variable within the template.
Link to default…

jebjeb
- 115
- 1
- 4
- 12
0
votes
1 answer
user management cookbook error
I am using the following cookbook from the github https://github.com/FFIN/user_management
Unfortunately i keep getting this error when i run the recipe
ERROR: undefined method each for nil:NilClass
The error seems to be originating from the second…

jebjeb
- 115
- 1
- 4
- 12
0
votes
2 answers
Creating multiple users in chef using Chef Vault
I have the following user credentials in my chef vault
$ knife vault show testusers
user1
user2
user3
The content of each individual user looks like this:
knife vault show testusers user1
comment: user one
id: user1
password:…

jebjeb
- 115
- 1
- 4
- 12
0
votes
1 answer
not_if not working as expected in bash resource
I have written a bash resource as follows:
bash 'initialize_vault' do
environment (node['vault']['env'])
code <<-EOH
vault init > /etc/vault/keys
EOH
not_if { vault init | grep 'initialized' }
end
It seems that not_if is not working as…

meallhour
- 13,921
- 21
- 60
- 117
0
votes
2 answers
Chef: set an environment variable to an attribute
I saw some answers to similar questions, such as how to set an attribute to an environment variable, or how to set an environment variable in the whole system. But that's not what I'm looking for here.
I understand that the variables will only be…

MisterStrickland
- 947
- 1
- 15
- 35
0
votes
1 answer
What is the best way to export env variable within Chef
I am trying to set env variable within Chef recipe so that after the recipe is run, I can do echo $VAR1
bash 'set_env_var' do
code <<-EOH
echo export VAR1="https://#{node['fqdn']}" >> /etc/profile
source /etc/profile
EOH
…

meallhour
- 13,921
- 21
- 60
- 117
0
votes
1 answer
Can I force a node to send its node object to chef server mid-recipe execution?
I'm doing this in a recipe:
tag('mytag')
nodeobjs = search(:node, 'tags:mytag')
On first run on a node search() won't find it (until it runs again).
I know the nodes build a local copy of their node object before sending it too the server. Is it…

red888
- 27,709
- 55
- 204
- 392
0
votes
1 answer
Is it possible to dynamically build an Elastic cluster with a single run list?
I'm using the Elasticsearch cookbook.
My ultimate goal:
Have 4 or more previously deployed VMs that are unconfigured to
run ES
I apply the same recipe/runlist to all of these nodes and it installs
and configures an ES cluster for me
Before I start…

red888
- 27,709
- 55
- 204
- 392
0
votes
1 answer
Using berks for local development only?
I don't want to use berks in production because I don't like the idea of nodes going out to the web to pull cookbooks (I only want them to pull them from the Chef server in the normal way). But I like using Berks for local development because it…

red888
- 27,709
- 55
- 204
- 392
0
votes
1 answer
Chef - looking for a better way to find the last octet of an IP address.
I'd like to know what would be the best way to populate a Chef attribute in a cookbook with the last octet of the IP address.
Here is how I do it now. It seems to work; however,I'd like to know how I can improve it.
default['application']['host_ip']…

Aaron Bandelli
- 1,238
- 2
- 14
- 16
0
votes
1 answer
Errors running cookbooks with chef-client
I'm trying to run a cookbook using chef-client by using "chef-apply default.rb" (where default.rb is the default recipe of the cookbook) but I keep getting the same error regardless of the cookbook I'm trying. Is what i'm doing incorrect? Is there…

ninesalt
- 4,054
- 5
- 35
- 75
0
votes
1 answer
Do nothing if the file doesn't exist - Chef Template
I create a cookbook for copying some folders to others. In template, I wrote linux commands like:
cp -r [some path] [some path]
cp -r [some path] [some path]
cp -r [some path] [some path]
...
But the last command copy files with specific extension…

pulpet112
- 43
- 2
- 10