Remove recipe from role


#1

Hey Guys,

I have a quick question… so in my base role I make use of the Dynect
cookbook to set DNS on the new node. However once the node is provisioned
I no longer need to run this recipe and would like to remove it from the
runlist. The problem is I am not seeing a way to remove a recipe from
within a nodes runlist, only remove roles entirely and recipes… So is
this possible or do I need to refactor things a bit and pull out the DynEct
cookbook from the role ?

Thanks!

-John


#2

On 19 Jun 2012, at 04:32, John Dyer wrote:

Hey Guys,

I have a quick question… so in my base role I make use of the Dynect cookbook to set DNS on the new node. However once the node is provisioned I no longer need to run this recipe and would like to remove it from the runlist. The problem is I am not seeing a way to remove a recipe from within a nodes runlist, only remove roles entirely and recipes… So is this possible or do I need to refactor things a bit and pull out the DynEct cookbook from the role ?

Thanks!

-John

node.run_list.remove(“recipe[dynect::default]”) should do the right thing (replace ‘dynect::default’ as appropriate;


#3

knife node run_list remove NODENAME ‘recipe[cookbookname::recipie]’

This may help.

On Tue, Jun 19, 2012 at 2:19 PM, Ash Berlin ash_opscode@firemirror.comwrote:

On 19 Jun 2012, at 04:32, John Dyer wrote:

Hey Guys,

I have a quick question… so in my base role I make use of the Dynect
cookbook to set DNS on the new node. However once the node is provisioned
I no longer need to run this recipe and would like to remove it from the
runlist. The problem is I am not seeing a way to remove a recipe from
within a nodes runlist, only remove roles entirely and recipes… So is
this possible or do I need to refactor things a bit and pull out the DynEct
cookbook from the role ?

Thanks!

-John

node.run_list.remove(“recipe[dynect::default]”) should do the right thing
(replace ‘dynect::default’ as appropriate;


Thanks
Meenakshi Agrawal
The secret of achievement is to hold a picture of a successful outcome in
the mind


#4

On Mon, Jun 18, 2012 at 8:32 PM, John Dyer johntdyer@gmail.com wrote:

Hey Guys,

I have a quick question… so in my base role I make use of the Dynect
cookbook to set DNS on the new node. However once the node is provisioned I
no longer need to run this recipe and would like to remove it from the
runlist. The problem is I am not seeing a way to remove a recipe from
within a nodes runlist, only remove roles entirely and recipes… So is
this possible or do I need to refactor things a bit and pull out the DynEct
cookbook from the role ?

The other suggestions would work to remove an item from the run_list
but if I understand you correctly, your dns cookbook isn’t on the
run_list directly, it’s in a role. So that won’t work. You can remove
the role, but that isn’t what you want. You can edit the role to
remove the recipe, but then the next time you spin up a node it won’t
be in the role. If the recipe is idempotent, why do you care if its
removed? Typically you’d want to leave it there so that it will
continue to revalidate the intended state on future chef runs.

If you really do need a one-time recipe, you’d need to put it on the
run_list directly (not in a role) but then I believe there’s a way
that you can make a recipe remove itself from the run_list so it could
make itself one-time. Alternatively, there was talk about override run
list and one shot recipe features a while back. I think some of that
was implemented and maybe could help but I don’t know the details.

KC


#5

On Tue, Jun 19, 2012 at 11:40:51AM -0700, KC Braunschweig wrote:

On Mon, Jun 18, 2012 at 8:32 PM, John Dyer johntdyer@gmail.com wrote:

Hey Guys,

I have a quick question… so in my base role I make use of the Dynect
cookbook to set DNS on the new node. However once the node is provisioned I
no longer need to run this recipe and would like to remove it from the
runlist. The problem is I am not seeing a way to remove a recipe from
within a nodes runlist, only remove roles entirely and recipes… So is
this possible or do I need to refactor things a bit and pull out the DynEct
cookbook from the role ?

The other suggestions would work to remove an item from the run_list
but if I understand you correctly, your dns cookbook isn’t on the
run_list directly, it’s in a role. So that won’t work. You can remove
the role, but that isn’t what you want. You can edit the role to
remove the recipe, but then the next time you spin up a node it won’t
be in the role. If the recipe is idempotent, why do you care if its
removed? Typically you’d want to leave it there so that it will
continue to revalidate the intended state on future chef runs.

If you really do need a one-time recipe, you’d need to put it on the
run_list directly (not in a role) but then I believe there’s a way
that you can make a recipe remove itself from the run_list so it could
make itself one-time. Alternatively, there was talk about override run
list and one shot recipe features a while back. I think some of that
was implemented and maybe could help but I don’t know the details.

KC is right, this is the wrong approach.

Instead, do something like this in default.rb:

is_provisioned = File.exists?(’/var/named/.is_provisioned’)

unless is_provisioned
include_recipe this_cookbook::provision
end

And then stick everything in the provision.rb and you’re done.


Phil Dibowitz phil@ipom.com
Open Source software and tech docs Insanity Palace of Metallica
http://www.phildev.net/ http://www.ipom.com/

“Be who you are and say what you feel, because those who mind don’t matter
and those who matter don’t mind.”

  • Dr. Seuss

#6

On Tue, Jun 19, 2012 at 11:47:53AM -0700, Phil Dibowitz wrote:

On Tue, Jun 19, 2012 at 11:40:51AM -0700, KC Braunschweig wrote:

On Mon, Jun 18, 2012 at 8:32 PM, John Dyer johntdyer@gmail.com wrote:

Hey Guys,

I have a quick question… so in my base role I make use of the Dynect
cookbook to set DNS on the new node. However once the node is provisioned I
no longer need to run this recipe and would like to remove it from the
runlist. The problem is I am not seeing a way to remove a recipe from
within a nodes runlist, only remove roles entirely and recipes… So is
this possible or do I need to refactor things a bit and pull out the DynEct
cookbook from the role ?

The other suggestions would work to remove an item from the run_list
but if I understand you correctly, your dns cookbook isn’t on the
run_list directly, it’s in a role. So that won’t work. You can remove
the role, but that isn’t what you want. You can edit the role to
remove the recipe, but then the next time you spin up a node it won’t
be in the role. If the recipe is idempotent, why do you care if its
removed? Typically you’d want to leave it there so that it will
continue to revalidate the intended state on future chef runs.

If you really do need a one-time recipe, you’d need to put it on the
run_list directly (not in a role) but then I believe there’s a way
that you can make a recipe remove itself from the run_list so it could
make itself one-time. Alternatively, there was talk about override run
list and one shot recipe features a while back. I think some of that
was implemented and maybe could help but I don’t know the details.

KC is right, this is the wrong approach.

Instead, do something like this in default.rb:

is_provisioned = File.exists?(’/var/named/.is_provisioned’)

unless is_provisioned
include_recipe this_cookbook::provision
end

And then stick everything in the provision.rb and you’re done.

Oh, I didn’t explicitly say it, but somewhere in provision.rb you need to
create ‘/var/named/.is_provisioned’ :slight_smile:


Phil Dibowitz phil@ipom.com
Open Source software and tech docs Insanity Palace of Metallica
http://www.phildev.net/ http://www.ipom.com/

“Be who you are and say what you feel, because those who mind don’t matter
and those who matter don’t mind.”

  • Dr. Seuss

#7

Chef 10.12.0 also supports “override run lists” which allow the
operator to temporarily override the run list w/o affecting the remote
saved Node.

You could make use of this functionality to run this recipe as a once off.

In my experience, we continuously run the dynect cookbook on every
node (recipe: a_record) and then CNAME additional records to the
original a_record. There is no reason to not run it every time – the
dynect provider’s actions are idempotent.

HTH,

–AJ

On 20 June 2012 07:02, Phil Dibowitz phil@ipom.com wrote:

On Tue, Jun 19, 2012 at 11:47:53AM -0700, Phil Dibowitz wrote:

On Tue, Jun 19, 2012 at 11:40:51AM -0700, KC Braunschweig wrote:

On Mon, Jun 18, 2012 at 8:32 PM, John Dyer johntdyer@gmail.com wrote:

Hey Guys,

I have a quick question… so in my base role I make use of the Dynect
cookbook to set DNS on the new node. However once the node is provisioned I
no longer need to run this recipe and would like to remove it from the
runlist. The problem is I am not seeing a way to remove a recipe from
within a nodes runlist, only remove roles entirely and recipes… So is
this possible or do I need to refactor things a bit and pull out the DynEct
cookbook from the role ?

The other suggestions would work to remove an item from the run_list
but if I understand you correctly, your dns cookbook isn’t on the
run_list directly, it’s in a role. So that won’t work. You can remove
the role, but that isn’t what you want. You can edit the role to
remove the recipe, but then the next time you spin up a node it won’t
be in the role. If the recipe is idempotent, why do you care if its
removed? Typically you’d want to leave it there so that it will
continue to revalidate the intended state on future chef runs.

If you really do need a one-time recipe, you’d need to put it on the
run_list directly (not in a role) but then I believe there’s a way
that you can make a recipe remove itself from the run_list so it could
make itself one-time. Alternatively, there was talk about override run
list and one shot recipe features a while back. I think some of that
was implemented and maybe could help but I don’t know the details.

KC is right, this is the wrong approach.

Instead, do something like this in default.rb:

is_provisioned = File.exists?(’/var/named/.is_provisioned’)

unless is_provisioned
include_recipe this_cookbook::provision
end

And then stick everything in the provision.rb and you’re done.

Oh, I didn’t explicitly say it, but somewhere in provision.rb you need to
create ‘/var/named/.is_provisioned’ :slight_smile:


Phil Dibowitz phil@ipom.com
Open Source software and tech docs Insanity Palace of Metallica
http://www.phildev.net/ http://www.ipom.com/

“Be who you are and say what you feel, because those who mind don’t matter
and those who matter don’t mind.”

  • Dr. Seuss