For completeness, I solved this myself by using a template instead of
trying to do this all within a manifest:
#!/bin/sh
<% databases.each do |db| -%>
<%= "mysqldump --user admin #{db} | gzip > mysql-#{db}-`date +%Y%m%d`.gz" %>
<% end -%>
<% remote_dest.each do |rd| -%>
<%= "rsync -arzv #{bkp_dest} #{rd}" %>
<% end -%>
And the manifest then simplifies to:
file { "backup-script":
ensure => present,
path => $mysql-backup-script,
content => template('backups/backup-mysql.erb'),
mode => 744,
owner => "root",
group => "root",
}
cron { "backup-mysql":
command => $mysql-backup-script,
hour => 1,
minute => 20,
require => File['backup-script'],
}
On Tuesday, July 23, 2013 1:32:43 PM UTC-4, Bret Wortman wrote:
>
> I'm trying to use a puppet manifest to set up a series of backup jobs on
> servers which are each running a variety of mysql databases. My manifest
> currently looks something like this, which almost works:
>
> class backups () {
>
> Cron {
> ensure => present,
> user => root,
> }
>
> $remote_dest = ['zx2:/data/src/backups','zx3:/data/backups']
>
> if $hostname == "www" {
> $databases = ['phpbb3','wikidb','rt4','wordpress']
> $bkp_dest = "/data/backup"
> elsif...
> :
> }
>
> cron { $databses:
> command => "mysqldump --user admin $databases | gzip >
> mysql-$databases-`date +%Y%m%d`.gz",
> hour => 1,
> minute => 20,
> }
>
> cron { $remote_dest:
> command => "rsync -arzv $bkp_dest $remote_dest",
> hour => 4,
> minute => 40,
> }
> }
>
> I get the right number of cron jobs built, but when the array variables
> are quoted, I get the contents all concatenated together. What I'd like is
> to simulate a "for x in array" kind of construct. Is that possible using
> puppet? I'd rather not have to build this and specify each job by hand,
> which seems really clunky given the elegance of the tool. I'm sure I'm just
> not seeing something.
>
> Thanks!
>
>
> Bret
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.