The quick way is to apply a pair of exec resources on the client machine:
- One that downloads the sql file and the other one (that requires the first
one) that applies it.
Something like:
exec {
"Retrieve $url":
cwd => "$work_dir",
command => "wget $url",
creates => "$work_dir/$sql_filename",
timeout => 3600,
}
exec {
"Extract $sql_filename":
command => "mysql $mysql_options < $work_dir/$sql_filename",
unless => "command that checks if the queryfile has been
processed",
require => Exec["Retrieve $url"],
}
An alternative approach would be to use puppi to "deploy" the sql file using
this define:
http://github.com/example42/puppi/blob/master/manifests/project/mysql.pp
In order to do this you should:
- Include puppi in your modules ( http://github.com/example42/puppi )
- Write a define like for your client node
puppi::project::mysql { "mysite_sql":
source => "http://url_to/mysite.sql",
mysql_user => "$mysql_user",
mysql_host => "$mysql_host",
mysql_database => "$mysql_database",
mysql_password => "$mysql_password",
report_email => "my@mail",
enable => "true",
}
- MANUALLY TYPE "puppi deploy mysite_sql" on the client node (or trigger it
via Puppet with an exec resource like the ones at the beginning).
Note that this Puppi approach might be a bit overkill for your needs: if you
have to apply the sql file statements only once the first approach is
quicker, if you plan to manage more or less continuous application
deployments where developers leave on http://url_to/mysite.sql the changes
on the database they require, the puppi approach saves time in the long term
(and gives a lot of extra features).
My2c
Al
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/puppet-users/-/5rmN0_gmyQ4J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.