mysqlbackup.sh should be able to find mysql

anywhere. This should enable use to use mysql::server::backup
idependantly, even if mysql is preinstalled, and preinstalled in non
standard locations
This commit is contained in:
Igor Galić 2014-02-20 17:17:41 +01:00
parent d2eea45749
commit d2b24e40d3
5 changed files with 12 additions and 1 deletions

View file

@ -313,6 +313,10 @@ Whether a separate file be used per database.
Allows you to remove the backup scripts. Can be 'present' or 'absent'. Allows you to remove the backup scripts. Can be 'present' or 'absent'.
#####`execpath`
Allows you to set a custom PATH should your mysql installation be non-standard places. Defaults to `/usr/bin:/usr/sbin:/bin:/sbin`
#####`time` #####`time`
An array of two elements to set the backup time. Allows ['23', '5'] or ['3', '45'] for HH:MM times. An array of two elements to set the backup time. Allows ['23', '5'] or ['3', '45'] for HH:MM times.

View file

@ -15,6 +15,7 @@ class mysql::server::backup (
$ensure = 'present', $ensure = 'present',
$time = ['23', '5'], $time = ['23', '5'],
$postscript = false, $postscript = false,
$execpath = '/usr/bin:/usr/sbin:/bin:/sbin',
) { ) {
mysql_user { "${backupuser}@localhost": mysql_user { "${backupuser}@localhost":

View file

@ -21,6 +21,7 @@ describe 'mysql::server::backup class' do
'cp -r /tmp/backups /var/tmp/mysqlbackups', 'cp -r /tmp/backups /var/tmp/mysqlbackups',
'touch /var/tmp/mysqlbackups.done', 'touch /var/tmp/mysqlbackups.done',
], ],
execpath => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin',
} }
EOS EOS

View file

@ -8,6 +8,7 @@ describe 'mysql::server::backup' do
'backupdir' => '/tmp', 'backupdir' => '/tmp',
'backuprotate' => '25', 'backuprotate' => '25',
'delete_before_dump' => true, 'delete_before_dump' => true,
'execpath' => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin',
} }
} }
context 'standard conditions' do context 'standard conditions' do
@ -51,6 +52,10 @@ describe 'mysql::server::backup' do
# MySQL counts from 0 I guess. # MySQL counts from 0 I guess.
should contain_file('mysqlbackup.sh').with_content(/.*ROTATE=24.*/) should contain_file('mysqlbackup.sh').with_content(/.*ROTATE=24.*/)
end end
it 'should have a standard PATH' do
should contain_file('mysqlbackup.sh').with_content(%r{PATH=/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin})
end
end end
context 'custom ownership and mode for backupdir' do context 'custom ownership and mode for backupdir' do

View file

@ -23,7 +23,7 @@ EVENTS="--events"
<% end %> <% end %>
##### STOP CONFIG #################################################### ##### STOP CONFIG ####################################################
PATH=/usr/bin:/usr/sbin:/bin:/sbin PATH=<%= @execpath %>