I’m using Vagrant + Chef Solo to set up a CakePHP app. I’d like to be able to call ‘cake schema create’ in my recipe to create the database schema. I’ve added the following to my default recipe:
execute "create-db" do
command "mysql -u root -p#{node[:mysql][:server_root_password]} -e 'CREATE DATABASE cakephp;'"
end
execute "load-db-schema" do
command "/vagrant/cakephp/lib/Cake/Console/cake schema create -app /vagrant/cakephp/app"
end
But the ‘cake schema create’ task requires user intervention (i.e. it prompts the user if they really want to drop all the tables and recreate them). There was this issue opened in late 2011, but it doesn’t look like it’s going anywhere…
Is there any way to configure chef to interact with the script?
If not, is there any way to get around this with CakePHP?
There’s currently no way of doing this with CakePHP. However, you can get around it by piping a series of answers into the script. I found the answer here.
If you want to answer
'y'to every prompt, you can use:If you just want to use defaults, you can use:
If you want to use specific responses, you can list them, separated by newline characters. This will send
'y'and then'n', dropping the tables, and not recreating them: