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
6
votes
1 answer

Chef - Dir.exists? guard treating symlink as directory

I have a recipe which deletes an empty logs directory, then replaces it with a symlink in the next step. directory "#{ENV['GS_HOME']}/logs/" do action :delete only_if { ::Dir.exists?("#{ENV['GS_HOME']}/logs/") } end It works the first time…
Daniel K
  • 115
  • 1
  • 1
  • 13
6
votes
1 answer

Manage website users, vhosts and PHP-FPM pools using Chef

I'm looking to automate my cloud environment fairly soon using Chef so it can automatically scale instances and add them to HAProxy. One issue I'm having is with the concept of managing multiple virtualhosts and the users created with them to use in…
MrNorm
  • 406
  • 4
  • 14
6
votes
1 answer

The apt recipe won't install within my recipe

I am attempting to create my first Chef recipe with Vagrant and have run into an issue at the very first step. The first line of my recipe is: include_recipe "apt" But when I try and vagrant provision I get the following error: ==> default:…
Ken
  • 626
  • 1
  • 8
  • 22
6
votes
1 answer

"include_recipe" vs. Vagrantfile "chef.add_recipe". What's the difference?

Just ran nginx::source recipe on my vagrant box, and I have very unusual behaviour. When I include a recipe from the Vagrantfile (as below), everything works like a charm, chef.add_recipe("project::nginx") …
Konzulic
  • 1,743
  • 14
  • 22
6
votes
1 answer

Chef: How do I check to see if a service is installed?

In a recipe I want to check to see if a service is installed, and if it is not notify the 3 resources needed to install it. I tried the service resource, which correctly identifies the service when it is installed, but throws an exception if the…
CPS
  • 531
  • 1
  • 9
  • 18
6
votes
1 answer

Override the chef bash return code

I am running a chef recipie to install Websphere fixpacks. The fixpack retuns and exitcode [2] which is for partial install. Its an expected behaviour, but chef is just taking it as an error. Is there any way to override it. I want chef to move…
Saurav
  • 414
  • 6
  • 17
6
votes
1 answer

Chef data bag creation from a recipe

How to create a data bag from a recipe and avoid the exception when that data bag already exists? The documentation shows that creating a data bag is done like this: new_databag =…
Evgeny
  • 6,533
  • 5
  • 58
  • 64
5
votes
1 answer

Chef isn't running the apt (apt-get update) recipe. Apt returns 100

Running Ubuntu 11.04 on vagrant, mac os x 10.7.2. Running chef server. Trying to install the postgresql community chef recipe, I get the following error, even though my base role looks something like this (I added the apt recipe to try to update…
Andres
  • 2,880
  • 4
  • 32
  • 38
5
votes
1 answer

How can I set up a dependency to a Ruby library which doesn't exist at the time Chef loads recipes?

Scenario: Recipe1: downloads archives, extracts them. Makes available a CLI which also defines a Ruby library. Recipe2: leverages Ruby API from the aforementioned library. In recipe1/recipes/default.rb: .. do work node[:recipe1][:filePath] = ".."…
elred
  • 51
  • 2
5
votes
2 answers

How do I view a recipe on a chef server?

knife search node '*:*' -a recipes gives me all the nodes and their recipes. knife node show NODE_ID -a recipes gives me recipes used by a specific node with NODE_ID. I need to fetch the contents of the recipes that these commands fetch. Even a…
ashokgadeking
  • 53
  • 1
  • 5
5
votes
1 answer

chef - using recipes from same cookbook

I have cookbook base and cookbook myapp base has 2 recipes - my_java and java_with_custom_stuff in java_with_custom_stuff I want to use the recipe for my_java (same cookbook). something like include_recipe 'my_java' bash 'custom stuff'…
Nick Ginanto
  • 31,090
  • 47
  • 134
  • 244
5
votes
2 answers

How to use library module in Cookbook recipes

In a cookbook I have a library(client_helper.rb). A module is defined inside it. Module name is Client_helper. Here is the module code. module Client_helper # This module contains helper methods def network_zone Chef::Log.debug('network…
Biswajit Das
  • 644
  • 7
  • 26
5
votes
1 answer

Chef - Run resource on other resource's failure

I have two execute resources called command_1 and command_2. If command_1 fails, I want to run command_2and then re-run command_1. Pretty much like this: execute 'command_1' do command "ipa host-del #{machine_name}" action :run ignore_failure…
JahMyst
  • 1,616
  • 3
  • 20
  • 39
5
votes
1 answer

Chef cannot get httpd depend

I am learning chef at the moment using OpsWorks , currently I am trying to create a recipe that will install 2 package in one instance. I stored my cookbook on github.. there I have a recipe that is like this - webserver.rb # Install apache and…
Drixson Oseña
  • 3,631
  • 3
  • 23
  • 36
5
votes
1 answer

How to use a Ruby block to assign variables in chef recipe

I am trying to execute Ruby logic on the fly in a Chef recipe and believe that the best way to achieve this is with a block. I am having difficulty transferring variables assigned inside the block to the main code of the chef recipe. This is what I…
ImmyGo
  • 53
  • 1
  • 1
  • 3
1 2
3
83 84