I'm using chef to install the default mysql-server
package on Ubuntu 16.04. I'm doing it on a server that has no existing MySQL installation, but does have /var/lib/mysql
set up already, as a mounted drive.
Thus, /var/lib/mysql
has a lost+found
directory in it.
If I install MySQL using very basic chef:
package 'mysql-server'
When /var/lib/mysql/lost+found
exists, I get an error:
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing package mysql-server-5.7 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.7; however:
Package mysql-server-5.7 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
(This error also happens if I simply apt-get install mysql-server
.)
However, if I remove the lost+found
directory before doing the installation, everything works fine.
I imagine that mysql's installation process does something like assuming the lost+found
directory is actually a database, and tries to upgrade it during the install, or something equally odd.
I've worked around this for now (and also proved to myself that the lost+found
directory is definitely the cause) by deleting lost+found
before the install, and recreating it afterwards:
directory '/var/lib/mysql/lost+found' do
action :delete
end
package 'mysql-server'
package 'mysql-client'
execute 'mklost+found' do
command 'mklost+found'
cwd '/var/lib/mysql'
end
This works fine, but I believe experts would probably rate it at around 8.2 on the standard Kludge-o-Rama scale.
Is there a better way to do the basic, package-default install of MySQL Server on Ubuntu using chef when /var/lib/mysql is already set up as a mounted drive?