From d2b24e40d3034026ccfa7f5af1eb9d418137665c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Gali=C4=87?= Date: Thu, 20 Feb 2014 17:17:41 +0100 Subject: [PATCH] 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 --- README.md | 4 ++++ manifests/server/backup.pp | 1 + spec/acceptance/mysql_backup_spec.rb | 1 + spec/classes/mysql_server_backup_spec.rb | 5 +++++ templates/mysqlbackup.sh.erb | 2 +- 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 03b6bbd..be0d9e2 100644 --- a/README.md +++ b/README.md @@ -313,6 +313,10 @@ Whether a separate file be used per database. 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` An array of two elements to set the backup time. Allows ['23', '5'] or ['3', '45'] for HH:MM times. diff --git a/manifests/server/backup.pp b/manifests/server/backup.pp index a33b2b0..d0f1af8 100644 --- a/manifests/server/backup.pp +++ b/manifests/server/backup.pp @@ -15,6 +15,7 @@ class mysql::server::backup ( $ensure = 'present', $time = ['23', '5'], $postscript = false, + $execpath = '/usr/bin:/usr/sbin:/bin:/sbin', ) { mysql_user { "${backupuser}@localhost": diff --git a/spec/acceptance/mysql_backup_spec.rb b/spec/acceptance/mysql_backup_spec.rb index 7831250..ee440f0 100644 --- a/spec/acceptance/mysql_backup_spec.rb +++ b/spec/acceptance/mysql_backup_spec.rb @@ -21,6 +21,7 @@ describe 'mysql::server::backup class' do 'cp -r /tmp/backups /var/tmp/mysqlbackups', 'touch /var/tmp/mysqlbackups.done', ], + execpath => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin', } EOS diff --git a/spec/classes/mysql_server_backup_spec.rb b/spec/classes/mysql_server_backup_spec.rb index c46f95b..53a9eda 100644 --- a/spec/classes/mysql_server_backup_spec.rb +++ b/spec/classes/mysql_server_backup_spec.rb @@ -8,6 +8,7 @@ describe 'mysql::server::backup' do 'backupdir' => '/tmp', 'backuprotate' => '25', 'delete_before_dump' => true, + 'execpath' => '/usr/bin:/usr/sbin:/bin:/sbin:/opt/zimbra/bin', } } context 'standard conditions' do @@ -51,6 +52,10 @@ describe 'mysql::server::backup' do # MySQL counts from 0 I guess. should contain_file('mysqlbackup.sh').with_content(/.*ROTATE=24.*/) 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 context 'custom ownership and mode for backupdir' do diff --git a/templates/mysqlbackup.sh.erb b/templates/mysqlbackup.sh.erb index ff38b23..de6a368 100755 --- a/templates/mysqlbackup.sh.erb +++ b/templates/mysqlbackup.sh.erb @@ -23,7 +23,7 @@ EVENTS="--events" <% end %> ##### STOP CONFIG #################################################### -PATH=/usr/bin:/usr/sbin:/bin:/sbin +PATH=<%= @execpath %>