[chef] how best to create and fill a database in an idempotent fashion?


Chronological Thread 
  • From: Dmitry V'yal < >
  • To:
  • Subject: [chef] how best to create and fill a database in an idempotent fashion?
  • Date: Thu, 01 Jul 2010 14:19:12 +0400
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; b=rfIDd43dSgLAQdE7nUej3FTlREO488Pv3rwYLcezjsCIZQXiQSIsp5kcQAw6jv07pI o0AZqpq7nEDjbW44as+jJT/RY2zZARahMYgXQ8vH6WbQw64oxHF/wvZzWm8gfR0y4umP kHz5vfYDqOR1o/IIOnL3ku1hFC3HQR6FpLAp8=

Hello list,

I'm writing a receipt which creates a mysql database for my mail server.
I wrote a sql script and call it like this:

***

root_pass = node[:mysql][:server_root_password]

scheme_path = "/tmp/scheme.sql"

template scheme_path do
  mode "600"
  source "mysql-scheme.sql.erb"
end

execute "mysql-scheme" do
  command "cat #{scheme_path} | mysql -u root -p#{root_pass}"
end

file scheme_path do
  action :delete
end

***

Of course, this worked only the first time, the next chef run mysql complained the database already exists.

How do you handle similar situations? What're the pros and cons of various approaches?

Thanks,
Dmitry



Archive powered by MHonArc 2.6.16.

§