[chef] Re: Re: Execute command on specific node (for versioning database on deployment)


Chronological Thread 
  • From: Kevin Harvey < >
  • To:
  • Subject: [chef] Re: Re: Execute command on specific node (for versioning database on deployment)
  • Date: Mon, 5 Dec 2011 09:23:23 -0500

Michael, thanks for you response. I agree that this stuff should be in the database cookbook. Right now we're only deploying single instances, but we'll eventually be deploying as a multi-instance infrastructure so I want to get this right.

Would you say the code I've included above (from the application cookbook) is in the wrong place? To date our whole strategy has been based on the quick start, so I hope that it is best practice.

We'd eventually like to have a corresponding copy of the database for each revision in the revisions directory. That happens in django.rb, and it would seem to make sense to do database migration from the same place.

Yes, a deploy is triggered on the Django server. If the Git repositiory has changed it grabs the new code and creates a new revision.

So, when it's all said and done, what's the right way to do this?

--
Kevin Harvey
Web Developer
" target="_blank">



On Wed, Nov 30, 2011 at 9:59 PM, Michael Schueler < "> > wrote:
Hi,

I don't think that nodes performing changes on other nodes is a good use case for chef, nor is it a good idea.  This stuff should be in your database cookbook.

If you don't really care about that and just want to do it anyways there are many different ways to do this.  I think that the simplest way would have the recipe pass dbm[:fqdn] to an external script to do this for you.  Or.. you could just put the whole thing into an execute block in your recipe.

This kind of stuff really belongs in your orchestration or deploy scripts

How do you trigger a deploy right now?  Issuing a chef run on your Django server?

On Wed, Nov 30, 2011 at 9:42 AM, Kevin Harvey < " target="_blank"> > wrote:
Hello all, I'm trying to keep versioned copies of my database with each new revision of my Django code. I'm working from the Django Quickstart.

In django.rb I have:

...
dbm = nil
  # If we are the database master
  if node.run_list.roles.include?(app["database_master_role"][0])
    dbm = node
  else
  # Find the database master
    results = search(:node, "role:#{app["database_master_role"][0]} AND chef_environment:#{node.chef_environment}", nil, 0, 1)
    rows = results[0]
    if rows.length == 1
      dbm = rows[0]
    end
  end
...

After this block I have the variable dbm, which should point to the node with the database_master role, whether that's the node I'm on or some other node. (Right?)

Is there a way I can use that variable to run commands just on that node from this recipe? I'd like to do a mysqldump, create a new database with the revision number, and load the dump into it in the before_migration callback in django.rb. Thanks in advance!

--
Kevin Harvey
Web Developer
" target="_blank">





  • [chef] Re: Re: Execute command on specific node (for versioning database on deployment), Kevin Harvey, 12/05/2011

Archive powered by MHonArc 2.6.16.

§