[chef] Re: Re: Fwd: Re: Fwd: Re: Fwd: Re: Newb question: How to extend a resource?


Chronological Thread 
  • From: Lamont Granquist < >
  • To: < >
  • Subject: [chef] Re: Re: Fwd: Re: Fwd: Re: Fwd: Re: Newb question: How to extend a resource?
  • Date: Wed, 14 Aug 2013 12:59:56 -0700


In the case under discussion it doesn't depend on inspecting the downloaded file, though, you know that  the target of the symlink is going to depend on the node['mything']['version'] attribute.  If you update the attribute, the link will update, if you don't update the attribute then the link resource will be idempotent.  Updating the attribute performs like a 'notification'.

On 8/14/13 11:25 AM, Mike wrote:
" type="cite">
Using a 'notifies' on the remote_file resource ought to do it. 
Read more on notifications here:

-M


On Wed, Aug 14, 2013 at 11:50 AM, Guy Matz < " target="_blank"> > wrote:
What I don't see is a way for the remote_file resource to notify the link that it should relink to the newly downloaded file . . .  is that possible?

Thanks again!!


On Wed, Aug 14, 2013 at 10:59 AM, Mike < " target="_blank"> > wrote:
For that you may wish to add another `link` resource, after the file has been downloaded.

Something like:

remot_file ....
end

link "/tmp/foo.zip" do
  to "/tmp/foo-version-#{node['mything']['version']}"
end


You could add notifications and default actions and stuff, depending on what you want to do.
-M


On Wed, Aug 14, 2013 at 10:49 AM, Guy Matz < " target="_blank"> > wrote:
Oops!  No, it's not quite that simple, actually.  What I need to do is have the version in my attributes file that I can download using remote_file, but I need to download it to an unversioned file, although I would prefer to download the to versioned filename, and have it linked to an unversioned name.

so, something like:
# in recipe:
  # Made up code here
  link /tmp/foo.zip
end

Thanks again,
Guy



On Tue, Aug 13, 2013 at 1:05 PM, Mike < " target="_blank"> > wrote:
Glad I could help!

I did indeed give such a talk - details are here: http://www.datadoghq.com/2013/06/hacking-your-daily-devops-experiences-nyc-devops-meetup-live-stream/

Best,
-M


On Tue, Aug 13, 2013 at 11:36 AM, Guy Matz < " target="_blank"> > wrote:
Yes!  Yes!!!  Thank you!!!  I think I recognize your picture . . .  did you ever give a 'lightning' presentation  on versioning of chef modules somewhere around broadway & 25th st?

Thanks again!
Guy


On Tue, Aug 13, 2013 at 10:34 AM, Mike < " target="_blank"> > wrote:
Hi Guy,

I'd like to understand what you're trying to achieve here. Consider:

# in attributes:
default['mything']['version'] = '1.0'

# in recipe:
remote_file "/tmp/foo" do
end

Then every time chef runs, it will look up the attribute, resolve it to a string, and use that as part of the source.

If anywhere along the attribute inheritance model I change that to be something else, say:

  override['mything']['version'] = '2.5'

Then the resulting file on the system should still be '/tmp/foo'.

Does that answer the problem?
-M



On Tue, Aug 13, 2013 at 10:19 AM, Guy Matz < " target="_blank"> > wrote:
Hi!  Newb here, coming from the puppet world!!  Seems that it's kinda easy to mangle chef, so I'm looking for the chefiest way and would appreciate some advice . . .

I would like to extend the remote_file resource so that it brings down a new file if  the name of the file on disk does not match that of the remote resource (The name of the remote resource would change due to an attribute change)

Any advice on how to approach this would be greatly appreciated!

regards,
Guy Matz














Archive powered by MHonArc 2.6.16.

§