Creating multiple recipes in one cookbook

Hi folks,

I am facing some issues in creating multiple recipes under same cookbook.
What am trying to achieve is say - I have a cookbook named "php" under
which I have recipes/default.rb. When I write ruby snippet to install php
having file name default.rb things works out to be fine,
but when I create a recipe name "php_install.rb" or "php_uninstall.rb" under
recipes directory and write the same code it doesn't allow me to install or
uninstall php respectively.
I also tried with an option* include_recipe "php" *in default.rb file.
Then too it didn't work out.

Where am I going wrong ?
Any inputs ?

Thank you,

Ashutosh Narayan

Ashutosh,

When you say "but when I create a recipe name "php_install.rb" or
"php_uninstall.rb" under
recipes directory and write the same code it doesn't allow me to install or
uninstall php respectively. "

What happens when you do it? Also, how are you calling these recipes, are
you using recipe[php::php_install] in case of php_install.rb recipe and so
on?

Thanks
Gourav

On Mon, Feb 18, 2013 at 7:42 PM, Ashutosh Narayan <
aashutoshnarayan@gmail.com> wrote:

Hi folks,

I am facing some issues in creating multiple recipes under same cookbook.
What am trying to achieve is say - I have a cookbook named "php" under
which I have recipes/default.rb. When I write ruby snippet to install php
having file name default.rb things works out to be fine,
but when I create a recipe name "php_install.rb" or "php_uninstall.rb"
under
recipes directory and write the same code it doesn't allow me to install or
uninstall php respectively.
I also tried with an option* include_recipe "php" *in default.rb file.
Then too it didn't work out.

Where am I going wrong ?
Any inputs ?

Thank you,

Ashutosh Narayan

http://ashutoshn.wordpress.com/

@Gourav,

What I did was after I ran the code from default.rb
I manually removed php from client box and
re-ran it using php_install.rb
It doesn't installs php and throws some error.

That's where my problem lies, how should call these recipes :frowning:
Presently, I just say include_recipe "php" in default.rb file.
Any pointers on how should I proceed ?

Thank you,

On Mon, Feb 18, 2013 at 7:48 PM, Gourav Shah gs@initcron.org wrote:

Ashutosh,

When you say "but when I create a recipe name "php_install.rb" or
"php_uninstall.rb" under
recipes directory and write the same code it doesn't allow me to install or
uninstall php respectively. "

What happens when you do it? Also, how are you calling these recipes, are
you using recipe[php::php_install] in case of php_install.rb recipe and so
on?

Thanks
Gourav

On Mon, Feb 18, 2013 at 7:42 PM, Ashutosh Narayan <
aashutoshnarayan@gmail.com> wrote:

Hi folks,

I am facing some issues in creating multiple recipes under same cookbook.
What am trying to achieve is say - I have a cookbook named "php" under
which I have recipes/default.rb. When I write ruby snippet to install php
having file name default.rb things works out to be fine,
but when I create a recipe name "php_install.rb" or "php_uninstall.rb"
under
recipes directory and write the same code it doesn't allow me to install
or
uninstall php respectively.
I also tried with an option* include_recipe "php" *in default.rb file.
Then too it didn't work out.

Where am I going wrong ?
Any inputs ?

Thank you,

Ashutosh Narayan

http://ashutoshn.wordpress.com/

--
Ashutosh Narayan

What I did was after I ran the code from default.rb
I manually removed php from client box and
re-ran it using php_install.rb
It doesn't installs php and throws some error.

are you specifically calling recipe[php::php_install] to run this? What
is your chef setup? Are you using chef-solo or chef -server?

That's where my problem lies, how should call these recipes :frowning:
Presently, I just say include_recipe "php" in default.rb file.
Any pointers on how should I proceed ?

From your description, I uderstand you are not applied this recipe in the
run_list. Correct way to do this would be remove recipe[php] (if you have
removed intall logic from there) and then add recipe[php:php_install] to
this node and then run chef-client/chef-solo

Thanks
Gourav

Thank you,

On Mon, Feb 18, 2013 at 7:48 PM, Gourav Shah gs@initcron.org wrote:

Ashutosh,

When you say "but when I create a recipe name "php_install.rb" or
"php_uninstall.rb" under
recipes directory and write the same code it doesn't allow me to
install or
uninstall php respectively. "

What happens when you do it? Also, how are you calling these recipes, are
you using recipe[php::php_install] in case of php_install.rb recipe and so
on?

Thanks
Gourav

On Mon, Feb 18, 2013 at 7:42 PM, Ashutosh Narayan <
aashutoshnarayan@gmail.com> wrote:

Hi folks,

I am facing some issues in creating multiple recipes under same cookbook.
What am trying to achieve is say - I have a cookbook named "php" under
which I have recipes/default.rb. When I write ruby snippet to install php
having file name default.rb things works out to be fine,
but when I create a recipe name "php_install.rb" or "php_uninstall.rb"
under
recipes directory and write the same code it doesn't allow me to install
or
uninstall php respectively.
I also tried with an option* include_recipe "php" *in default.rb file.
Then too it didn't work out.

Where am I going wrong ?
Any inputs ?

Thank you,

Ashutosh Narayan

http://ashutoshn.wordpress.com/

--
Ashutosh Narayan

http://ashutoshn.wordpress.com/

On Mon, Feb 18, 2013 at 7:58 PM, Gourav Shah gs@initcron.org wrote:

What I did was after I ran the code from default.rb

I manually removed php from client box and
re-ran it using php_install.rb
It doesn't installs php and throws some error.

are you specifically calling recipe[php::php_install] to run this? What
is your chef setup? Are you using chef-solo or chef -server?

No, I am not calling recipe[php::php_install] to run this.
I have a client-server setup with Chef server version 10.18

That's where my problem lies, how should call these recipes :frowning:
Presently, I just say include_recipe "php" in default.rb file.
Any pointers on how should I proceed ?

From your description, I uderstand you are not applied this recipe in the
run_list. Correct way to do this would be remove recipe[php] (if you have
removed intall logic from there) and then add recipe[php:php_install] to
this node and then run chef-client/chef-solo

I have added recipe[php] in run_list and not recipe[php:php_install]

Thanks
Gourav

Thank you,

On Mon, Feb 18, 2013 at 7:48 PM, Gourav Shah gs@initcron.org wrote:

Ashutosh,

When you say "but when I create a recipe name "php_install.rb" or
"php_uninstall.rb" under
recipes directory and write the same code it doesn't allow me to
install or
uninstall php respectively. "

What happens when you do it? Also, how are you calling these recipes,
are you using recipe[php::php_install] in case of php_install.rb recipe and
so on?

Thanks
Gourav

On Mon, Feb 18, 2013 at 7:42 PM, Ashutosh Narayan <
aashutoshnarayan@gmail.com> wrote:

Hi folks,

I am facing some issues in creating multiple recipes under same
cookbook.
What am trying to achieve is say - I have a cookbook named "php" under
which I have recipes/default.rb. When I write ruby snippet to install
php
having file name default.rb things works out to be fine,
but when I create a recipe name "php_install.rb" or "php_uninstall.rb"
under
recipes directory and write the same code it doesn't allow me to
install or
uninstall php respectively.
I also tried with an option* include_recipe "php" *in default.rb file.
Then too it didn't work out.

Where am I going wrong ?
Any inputs ?

Thank you,

Ashutosh Narayan

http://ashutoshn.wordpress.com/

--
Ashutosh Narayan

http://ashutoshn.wordpress.com/

--
Ashutosh Narayan

You need to explicitly call any recipe that isn't default:

include_recipe "php::php_install"

Michael Glenney
Sent from my iPhone

On Feb 18, 2013, at 7:12 AM, Ashutosh Narayan aashutoshnarayan@gmail.com wrote:

Hi folks,

I am facing some issues in creating multiple recipes under same cookbook.
What am trying to achieve is say - I have a cookbook named "php" under
which I have recipes/default.rb. When I write ruby snippet to install php
having file name default.rb things works out to be fine,
but when I create a recipe name "php_install.rb" or "php_uninstall.rb" under
recipes directory and write the same code it doesn't allow me to install or
uninstall php respectively.
I also tried with an option include_recipe "php" in default.rb file.
Then too it didn't work out.

Where am I going wrong ?
Any inputs ?

Thank you,

Ashutosh Narayan

http://ashutoshn.wordpress.com/

On Mon, Feb 18, 2013 at 8:03 PM, Michael Glenney mike.glenney@gmail.comwrote:

You need to explicitly call any recipe that isn't default:

include_recipe "php::php_install"

This worked for us.
Thank you,

Michael Glenney
Sent from my iPhone

On Feb 18, 2013, at 7:12 AM, Ashutosh Narayan aashutoshnarayan@gmail.com
wrote:

Hi folks,

I am facing some issues in creating multiple recipes under same cookbook.
What am trying to achieve is say - I have a cookbook named "php" under
which I have recipes/default.rb. When I write ruby snippet to install php
having file name default.rb things works out to be fine,
but when I create a recipe name "php_install.rb" or "php_uninstall.rb"
under
recipes directory and write the same code it doesn't allow me to install or
uninstall php respectively.
I also tried with an option* include_recipe "php" *in default.rb file.
Then too it didn't work out.

Where am I going wrong ?
Any inputs ?

Thank you,

Ashutosh Narayan

http://ashutoshn.wordpress.com/

--
Ashutosh Narayan