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


Chronological Thread 
  • From: Kevin Harvey < >
  • To:
  • Subject: [chef] Execute command on specific node (for versioning database on deployment)
  • Date: Wed, 30 Nov 2011 12:42:06 -0500

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">




Archive powered by MHonArc 2.6.16.

§