Skip to content

Instantly share code, notes, and snippets.

@Atalanta
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save Atalanta/bbe294092ef0f3bb4486 to your computer and use it in GitHub Desktop.

Select an option

Save Atalanta/bbe294092ef0f3bb4486 to your computer and use it in GitHub Desktop.
include_recipe 'mysql::server'
include_recipe 'database::mysql'
mysql_connection_info = {:host => "localhost",
:username => 'root',
:password => node['mysql']['server_root_password']}
service 'mysql-upstart' do
name 'mysql'
pattern 'mysql'
provider Chef::Provider::Service::Upstart
stop_command '/sbin/stop mysql'
status_command '/sbin/status mysql'
restart_command '/sbin/restart mysql'
action :nothing
end
service 'mysql-init' do
pattern 'mysql'
provider Chef::Provider::Service::Init
stop_command '/etc/init.d/mysql stop'
status_command '/etc/init.d/mysql status'
restart_command '/etc/init.d/mysql start'
action :nothing
end
file '/etc/init.d/mysql' do
action :delete
notifies :stop, 'service[mysql-init]', :immediately
end
link '/etc/init.d/mysql' do
to '/etc/init/mysql.conf'
notifies :restart, 'service[mysql]', :immediately
end
mysql_database 'test' do
connection mysql_connection_info
action :create
end
mysql_database_user 'test' do
connection mysql_connection_info
password 'test'
action :grant
end
include_recipe 'mysql::server'
include_recipe 'database::mysql'
mysql_connection_info = {:host => "localhost",
:username => 'root',
:password => node['mysql']['server_root_password']}
service 'mysql-init' do
name 'mysql'
provider Chef::Provider::Service::Init
action :nothing
end
service 'mysql-upstart' do
name 'mysql'
pattern 'mysql'
provider Chef::Provider::Service::Upstart
stop_command '/sbin/stop mysql'
action [:stop, :disable]
only_if { File.exists?('/etc/init/mysql.conf') }
end
file '/etc/init/mysql.conf' do
action :delete
notifies :restart, 'service[mysql]', :immediately
end
mysql_database 'test' do
connection mysql_connection_info
action :create
end
mysql_database_user 'test' do
connection mysql_connection_info
password 'test'
action :grant
end
* service[mysql] action nothing[2014-09-23T06:36:01+00:00] INFO: Processing service[mysql] action nothing (dbtest::database line 9)
(skipped due to action :nothing)
* service[mysql] action stop[2014-09-23T06:36:01+00:00] INFO: Processing service[mysql] action stop (dbtest::database line 15)
(up to date)
* service[mysql] action disable[2014-09-23T06:36:01+00:00] INFO: Processing service[mysql] action disable (dbtest::database line 15)
(up to date)
* file[/etc/init/mysql.conf] action delete[2014-09-23T06:36:01+00:00] INFO: Processing file[/etc/init/mysql.conf] action delete (dbtest::database line 24)
[2014-09-23T06:36:01+00:00] INFO: file[/etc/init/mysql.conf] backed up to /tmp/kitchen/backup/etc/init/mysql.conf.chef-20140923063601.121459
[2014-09-23T06:36:01+00:00] INFO: file[/etc/init/mysql.conf] deleted file at /etc/init/mysql.conf
- delete file /etc/init/mysql.conf
[2014-09-23T06:36:01+00:00] INFO: file[/etc/init/mysql.conf] sending restart action to service[mysql] (immediate)
* service[mysql] action restart[2014-09-23T06:36:01+00:00] INFO: Processing service[mysql] action restart (dbtest::database line 15)
(skipped due to only_if)
* mysql_database[test] action create[2014-09-23T06:36:01+00:00] INFO: Processing mysql_database[test] action create (dbtest::database line 29)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment