[chef] Re: Using data generated in a LWRP


Chronological Thread 
  • From: Andrea Campi < >
  • To:
  • Subject: [chef] Re: Using data generated in a LWRP
  • Date: Fri, 6 Apr 2012 08:36:34 +0200

On Mon, Apr 2, 2012 at 7:21 PM, Nick Peirson 
< >
 wrote:
> Hi all,
>
> I've only been using chef for a couple of months, so bear with me if I
> mangle the terminology :)
>
> I've got a LWRP that's creating an AWS RDS instance. Within the LWRP I wait
> till the RDS instance becomes available (while loop + sleep) and get it's
> details, of which I'm particularly interested in the endpoint address. I can
> log this by doing something along the lines of:
>
> Chef::Log.info("RDS endpoint address is #{rds_instance[:endpoint_address]}")
>
> What I now want to do is subscribe to the resource that's using this
> provider to create the rds_instance and for the subscribing resource to have
> the rds_instance object available, particularly the endpoint address. The
> subscribing resource is then going to connect to the RDS instance create a
> database, set up some permissions, etc.
>
> Is there a way to pass this information, e.g. something along the lines of
> making the rds_instance object available? If not, my other thought is to
> store it on the node or in a data bag, but this seems like a hack to get
> round a limitation that's only there due to my lack of knowledge.

I've done a spike on my idea and it looks doable. However, that made
me think harder and I'm not sure it's such a great idea.

Say you have resources A and B that both notify resource C.
At the risk of over-generalizing, I'm assuming C may then respond
differently based on who notified it.
The consequence then is that C will likely not be idempotent.

As another way to look at it, imagine the run fails between the moment
A triggers it and when C runs.
On the next run, C will not be notified and will likely do nothing.
There are a bunch of assumptions in here, but in general, you don't want this.

In your case, I would create a node attribute with your RDS endpoint.
C could then be written in an idempotent way; for example, it would
somehow notice that the address has changed on one or more resource,
and do its thing.

Hand-waving aside, would this make sense for you?

Andrea



Archive powered by MHonArc 2.6.16.

§