Questions tagged [chef-recipe]

A recipe is the most fundamental configuration element in Chef. Recipes specify which resources to manage and the order in which those resources will be applied.

A recipe is the fundamental configuration element in the Chef configuration-management tool. Recipes specify which resources to manage and the order in which those resources will be applied. A recipe:

  • Is authored using Ruby, which is a programming language designed to read and behave in a predictable manner
  • Is mostly a collection of resources in a Ruby syntax with some helper code around it
  • Must define everything that is required to configure part of a system
  • Must be stored in a cookbook
  • May be included in a recipe
  • May use the results of a search query and read the contents of a data bag (including an encrypted data bag)
  • May have a dependency on one (or more) recipes
  • May be tagged to facilitate the creation of arbitrary groupings that exist outside of the normal naming conventions an organization may have
  • Must be added to a run-list before it can be used by the chef-client Is always executed in the same order as listed in a run-list
1255 questions
11
votes
1 answer

Adding role to node does not work

I am following exact syntax but seeing some strange behavior while adding role to one of my nodes I am running following command which should ideally add role - webserver to do_node knife node run_list add do_node 'role[webserver]' But instead this…
Vishal Biyani
  • 4,297
  • 28
  • 55
10
votes
3 answers

Error when running 'vagrant up' -- Too many open files - getcwd (Errno::EMFILE)

I have a very basic Vagrantfile, and when I call 'vagrant up' for the first time (after destroying the box) I get the error below just about every time. Any ideas why? I'm at a loss. I'm on OSX. Vagrantfile: # -*- mode: ruby -*- # vi: set ft=ruby…
99miles
  • 10,942
  • 18
  • 78
  • 123
9
votes
4 answers

How to unzip tar.Z file through CHEF cookbooks

I'm using a Chef hosted server, a workstation and nodes and have run cookbooks on the nodes to install Java, update hosts file. I'm not able to find a reference in sites to unzip tar files. Could you please help me out here or direct to some site…
Azuretechie
  • 103
  • 1
  • 1
  • 4
9
votes
2 answers

how to make chef execute with a specific user and load its environment values

Hi I am creating a WCS instance, for which i have to execute the create instance command using the wcs user (webadmin), its failing to connect to DB as its not able to get the required env variables. so i put some sample code to check I am using the…
Saurav
  • 414
  • 6
  • 17
8
votes
2 answers

Chef Recipe How To Check If File Exists

I just started using Chef and I'm trying to figure out how to first check if a file exists before doing anything. I have the file part down for my current use case, where I'm removing a login file for the production server, ex: file…
Corey
  • 481
  • 2
  • 5
  • 11
8
votes
1 answer

Get IP address of node returned by chef search in recipe

How can I get IP address returned by node search in chef recipe (ruby). dbnodes = search(:node, "role:Db") Chef::Log.info(dbnodes.first["ipaddress"]) # nil Few weeks ago this code returned IP of first instance from search API. version: Chef:…
Matej
  • 7,517
  • 2
  • 36
  • 45
7
votes
3 answers

Chef: Read variable from file and use it in one converge

I have the following code which downloads a file and then reads the contents of the file into a variable. Using that variable, it executes a command. This recipe will not converge because /root/foo does not exist during the compile phase. I can…
jsmickey
  • 718
  • 10
  • 20
7
votes
4 answers

How to disable cookbook synchronization with chef-client?

I would like to test/debug cookbooks. However, using chef-client to restart a chef run, this requires me to modify cookbooks, upload them to the chef server & synchronize cookbooks. I would like to be able to modify the cookbooks that were…
eloaf
  • 101
  • 1
  • 2
  • 6
7
votes
3 answers

How to include_recipe inside a ruby_block of a chef recipe

I have a recipe that sets a variable inside a ruby_block and needs to use that variable as an input attribute for a recipe. How can I use the include_recipe after the ruby_block has been executed? Thanks ruby_block "evaluate_config" do #~FC014 …
JoseOlcese
  • 532
  • 6
  • 14
7
votes
1 answer

What's freezing my cookbooks?

Quick question. How come whenever I use Berkshelf to manage my cookbook dependencies, my own cookbooks get frozen? Is there a way to unfreeze it? knife cookbook upload myNodeApp Uploading myNodeApp [0.1.0] ERROR: Version 0.1.0 of cookbook…
YarGnawh
  • 4,574
  • 6
  • 26
  • 37
7
votes
1 answer

How do you modularize a Chef recipe?

Here is an example of a working recipe that loops through an array of website names and creates them in IIS using the function createIisWebsite(). def createIisWebsite(websiteName) iis_site websiteName do protocol :http port 80 …
Janaka
  • 307
  • 3
  • 10
7
votes
2 answers

Best way to rename a file with chef

How can I rename a file with chef? In the chef doc I found only: create create_if_missing delete touch
Rusty Robot
  • 1,305
  • 1
  • 12
  • 18
6
votes
2 answers

chef - STDERR: The python_package resource requires pip >= 6.1.0, currently 10.0.0

I am trying to bootstrap an server. I used to use "recipe[poise-python]" to pip install packages. Now I get the below error. How do fix? * python_package[setuptools] action upgrade …
Tampa
  • 75,446
  • 119
  • 278
  • 425
6
votes
4 answers

How to make newly created user as sudo user by using chef

I have created a user 'testuser' by using chef. How to make this user as sudo user?
Sampath
  • 137
  • 3
  • 11
6
votes
2 answers

File delete action if condition exists

New to chef recipe and google is not showing me an example of what I need to do. I have a file that I want deleted when chef finds it exists. I am not finding any google examples of something like file /path/foo do action delete end if /path/foo…
peter cooke
  • 987
  • 3
  • 10
  • 28
1
2
3
83 84