Notifications almost but not quite :immediate?


#1

I’m wondering if there is a way to get notifications to be delayed slightly, without having to wait for the end of the run?

Here is the scenario: I add several Yum repositories using a recipe. After the repositories are added, I need to rebuild the Yum cache.

I have two options to do that:

  • Send a delayed notification - but then other recipes don’t get the benefit of the new repositories until the next run, and thus may break.

  • Send an immediate notification - but then the cache gets rebuilt multiple times. Rebuilding the Yum cache is very expensive in terms of time and bandwidth, so I want to avoid that.

Is there a trick I can use to only cause one notification to be sent after all of the repositories have been added?

Thanks!


#2

Have you tried adding repos using the yum cookbook? This should take care of what you need.

John

On Sunday, September 22, 2013 at 9:22 AM, Kevin Keane Subscription wrote:

Notifications almost but not quite :immediate ? I’m wondering if there is a way to get notifications to be delayed slightly, without having to wait for the end of the run?

Here is the scenario: I add several Yum repositories using a recipe. After the repositories are added, I need to rebuild the Yum cache.

I have two options to do that:

  • Send a delayed notification - but then other recipes don’t get the benefit of the new repositories until the next run, and thus may break.

  • Send an immediate notification - but then the cache gets rebuilt multiple times. Rebuilding the Yum cache is very expensive in terms of time and bandwidth, so I want to avoid that.

Is there a trick I can use to only cause one notification to be sent after all of the repositories have been added?

Thanks!


#3

John,
The yum repository resource from that cookbook will execute the makecache
command for each repo added, notified immediately. This is no different
from the OP’s problem of getting them all to run once.

I face a similar issue with the apt cookbook.
-M

On Sunday, September 22, 2013, John Dewey wrote:

Have you tried adding repos using the yum cookbook? This should take care
of what you need.

https://github.com/opscode-cookbooks/yum

John

On Sunday, September 22, 2013 at 9:22 AM, Kevin Keane Subscription wrote:

I’m wondering if there is a way to get notifications to be delayed
slightly, without having to wait for the end of the run?

Here is the scenario: I add several Yum repositories using a recipe. After
the repositories are added, I need to rebuild the Yum cache.

I have two options to do that:

  • Send a delayed notification - but then other recipes don’t get the
    benefit of the new repositories until the next run, and thus may break.

  • Send an immediate notification - but then the cache gets rebuilt
    multiple times. Rebuilding the Yum cache is very expensive in terms of time
    and bandwidth, so I want to avoid that.

Is there a trick I can use to only cause one notification to be sent after
all of the repositories have been added?

Thanks!


#4

Sure, I still don’t see it as that big of an issue. :confused: Happens once when the repo is added.

On Sunday, September 22, 2013 at 1:57 PM, Mike wrote:

John,
The yum repository resource from that cookbook will execute the makecache command for each repo added, notified immediately. This is no different from the OP’s problem of getting them all to run once.

I face a similar issue with the apt cookbook.
-M

On Sunday, September 22, 2013, John Dewey wrote:

Have you tried adding repos using the yum cookbook? This should take care of what you need.

https://github.com/opscode-cookbooks/yum

John

On Sunday, September 22, 2013 at 9:22 AM, Kevin Keane Subscription wrote:

I’m wondering if there is a way to get notifications to be delayed slightly, without having to wait for the end of the run?

Here is the scenario: I add several Yum repositories using a recipe. After the repositories are added, I need to rebuild the Yum cache.

I have two options to do that:

  • Send a delayed notification - but then other recipes don’t get the benefit of the new repositories until the next run, and thus may break.

  • Send an immediate notification - but then the cache gets rebuilt multiple times. Rebuilding the Yum cache is very expensive in terms of time and bandwidth, so I want to avoid that.

Is there a trick I can use to only cause one notification to be sent after all of the repositories have been added?

Thanks!


#5

Hi,

On Mon, Sep 23, 2013 at 2:22 AM, Kevin Keane Subscription <
subscription@kkeane.com> wrote:

**
Is there a trick I can use to only cause one notification to be sent after
all of the repositories have been added?

We have needed to do this all over our infrastructure and the simple/ugly
way of doing it is creating a LWRP and invoking the "use_inline_resources"
in the provider.


Cheers,

Peter Donald


#6

Ugh. Accidentally sent before completing email …

On Mon, Sep 23, 2013 at 9:09 AM, Peter Donald peter@realityforge.orgwrote:

Hi,

On Mon, Sep 23, 2013 at 2:22 AM, Kevin Keane Subscription <
subscription@kkeane.com> wrote:

**
Is there a trick I can use to only cause one notification to be sent
after all of the repositories have been added?

We have needed to do this all over our infrastructure and the simple/ugly
way of doing it is creating a LWRP and invoking the "use_inline_resources"
in the provider.

We then go and declare all the resources we want to converge notifications
for and make notifications as delayed. Then when the LWRP completes it will
only process the notification once at the end of the group. Something like
[1].

However we have thought about creating a new LWRP that searches pending
notifications and runs those matching a name and removes them from the
pending list but I am not sure if we have done that at this stage.

[1]


Cheers,

Peter Donald


#7

Yes, I’m actually using the Yum cookbook.

Kevin Keane

The NetTech

760-721-8339

http://www.4nettech.com

Our values: Privacy, Liberty, Justice

See https://www.4nettech.com/corp/the-nettech-values.html

-----Original message-----
From: John Dewey john@dewey.ws
Sent: Sunday 22nd September 2013 9:27
To: chef@lists.opscode.com
Subject: [chef] Re: Notifications almost but not quite :immediate ?

Have you tried adding repos using the yum cookbook? This should take care of what you need.

John

On Sunday, September 22, 2013 at 9:22 AM, Kevin Keane Subscription wrote:

I’m wondering if there is a way to get notifications to be delayed slightly, without having to wait for the end of the run?

Here is the scenario: I add several Yum repositories using a recipe. After the repositories are added, I need to rebuild the Yum cache.

I have two options to do that:

  • Send a delayed notification - but then other recipes don’t get the benefit of the new repositories until the next run, and thus may break.

  • Send an immediate notification - but then the cache gets rebuilt multiple times. Rebuilding the Yum cache is very expensive in terms of time and bandwidth, so I want to avoid that.

Is there a trick I can use to only cause one notification to be sent after all of the repositories have been added?

Thanks!


#8

It may not be a big issue for you, but it can be when you are on a slow Internet connection, or when you pay by the megabyte.

Kevin Keane

The NetTech

760-721-8339

http://www.4nettech.com

Our values: Privacy, Liberty, Justice

See https://www.4nettech.com/corp/the-nettech-values.html

-----Original message-----
From: John Dewey john@dewey.ws
Sent: Sunday 22nd September 2013 14:45
To: chef@lists.opscode.com
Subject: [chef] Re: Re: Notifications almost but not quite :immediate ?

Sure, I still don’t see it as that big of an issue. :confused: Happens once when the repo is added.

On Sunday, September 22, 2013 at 1:57 PM, Mike wrote:

John,
The yum repository resource from that cookbook will execute the makecache command for each repo added, notified immediately. This is no different from the OP’s problem of getting them all to run once.

I face a similar issue with the apt cookbook.
-M

On Sunday, September 22, 2013, John Dewey wrote:

Have you tried adding repos using the yum cookbook? This should take care of what you need.

John

On Sunday, September 22, 2013 at 9:22 AM, Kevin Keane Subscription wrote:

I’m wondering if there is a way to get notifications to be delayed slightly, without having to wait for the end of the run?

Here is the scenario: I add several Yum repositories using a recipe. After the repositories are added, I need to rebuild the Yum cache.

I have two options to do that:

  • Send a delayed notification - but then other recipes don’t get the benefit of the new repositories until the next run, and thus may break.

  • Send an immediate notification - but then the cache gets rebuilt multiple times. Rebuilding the Yum cache is very expensive in terms of time and bandwidth, so I want to avoid that.

Is there a trick I can use to only cause one notification to be sent after all of the repositories have been added?

Thanks!


#9

On Monday, September 23, 2013 at 7:23 AM, Kevin Keane Subscription wrote:

RE: [chef] Re: Re: Notifications almost but not quite :immediate ?

On Sunday, September 22, 2013 at 9:22 AM, Kevin Keane Subscription wrote:

I’m wondering if there is a way to get notifications to be delayed slightly, without having to wait for the end of the run?

Here is the scenario: I add several Yum repositories using a recipe. After the repositories are added, I need to rebuild the Yum cache.

I have two options to do that:

  • Send a delayed notification - but then other recipes don’t get the benefit of the new repositories until the next run, and thus may break.

  • Send an immediate notification - but then the cache gets rebuilt multiple times. Rebuilding the Yum cache is very expensive in terms of time and bandwidth, so I want to avoid that.

Is there a trick I can use to only cause one notification to be sent after all of the repositories have been added?

Thanks!

There’s nothing built-in to do what you want, but it should be possible as an LWRP:

Using the #resources method, you can get a reference to a resource by its name: http://docs.opscode.com/dsl_recipe_method_resources.html Or you can access the resource collection via the run_context (e.g. run_context.resource_collection) and then look through each item: https://github.com/opscode/chef/blob/master/lib/chef/resource_collection.rb

Using this, you can find all the resources you’re interested in, and check if they’re updated with Resouce#updated?, which would then take the desired action.


Daniel DeLeo