Reputation: 2856
I'm trying to install mysql recipe in vagrant. I use this cookbook for that.
MySql service starts after vagrant up
, but after reboot I can't perform neither vagrant provision
or vagrant up
, because the server fails to start.
I have realized, that Vagrant wipes /var/run
directory; it creates mysqld directory (for socket), but not mysql (for pid file). MySql can't find the directory and can't create pid file.
How can I make it work? Why Vagrant creates mysqld, but not mysql?
I also tried it with different boxes (precise32, cloud daily precise64).
Box: http://files.vagrantup.com/precise32.box Vagrantfile:
Vagrant.configure("2") do |config| config.vm.box = "precise32" config.omnibus.chef_version = :latest config.vm.box_url = "http://files.vagrantup.com/precise32.box" config.vm.network :forwarded_port, guest: 8000, host: 8080 config.vm.provider :virtualbox do |vb| vb.gui = true end config.vm.provision :chef_solo do |chef| chef.cookbooks_path = "./chef-repo/cookbooks" chef.add_recipe "apt" chef.add_recipe "mysql::server" chef.json = { "mysql" => { "server_root_password" => "password", "server_repl_password" => "password", "server_debian_password" => "password" } } end end
Upvotes: 0
Views: 1107
Reputation: 1329
eviltnan is correct. Here's a scripted workaround for a first run ubuntu 12.04.
ruby_block "ensure mysql server starts on reboot" do
block do
fe = Chef::Util::FileEdit.new("/etc/mysql/my.cnf")
fe.search_file_replace_line(/pid-file/, 'pid-file = /var/run/mysqld/mysql.pid')
Chef::Log.warn("Edited /etc/mysql/my.cnf to re-enable start on reboot.") if fe.write_file
end
end
Upvotes: 0
Reputation: 2856
The problem is in MySql cookbook: somehow /var/run/mysqld is not wiped, so the workaround would be: change in <mysql_cookbook>/libraries/provider_mysql_service_ubuntu.rb
pid_file = '/var/run/mysql/mysql.pid'
to
pid_file = '/var/run/mysqld/mysqld.pid'
I make also an issue on github, so in the future the bug could be fixed in master
Upvotes: 1