Skip to content

Commit

Permalink
Adding log entries when slave/masters are created.
Browse files Browse the repository at this point in the history
  • Loading branch information
cparedes committed Jan 11, 2011
1 parent eea6142 commit 79e277c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions mysql/definitions/master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
if params[:action] == :create
ruby_block "connect-to-master-#{params[:name]}" do
block do
Chef::Log.info("Setting master host to #{params[:ip_address]} on port #{params[:port]}, with user #{params[:replication_user]}, log file at #{params[:master_log_file]}, position #{params[:master_log_pos]}")
%x[mysql -u root -e "CHANGE MASTER TO master_host='#{params[:ip_address]}', master_port=#{params[:port]}, master_user='#{params[:replication_user]}', master_password='#{params[:replication_password]}', master_log_file='#{params[:master_log_file]}', master_log_pos=#{params[:master_log_pos]};"]
%x[mysql -u root -e "START SLAVE;"]
end
Expand Down
1 change: 1 addition & 0 deletions mysql/definitions/slave.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
if params[:action] == :create
ruby_block "create-replication-#{params[:name]}-user" do
block do
Chef::Log.info("Granting replication slave on *.* to #{params[:replication_user]}@#{params[:ip_address]}")
%x[mysql -u root -e "GRANT REPLICATION SLAVE ON *.* TO '#{params[:replication_user]}'@'#{params[:ip_address]}' IDENTIFIED BY '#{params[:replication_password]}';"]
end
not_if "mysql -u root -e \"SELECT user,host from mysql.user where user='#{params[:replication_user]}';\" | grep #{params[:replication_user]} | grep #{params[:ip_address]}"
Expand Down
1 change: 1 addition & 0 deletions percona/definitions/master.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
if params[:action] == :create
ruby_block "connect-to-master-#{params[:name]}" do
block do
Chef::Log.info("Setting master host to #{params[:ip_address]} on port #{params[:port]}, with user #{params[:replication_user]}, log file at #{params[:master_log_file]}, position #{params[:master_log_pos]}")
%x[mysql -u root -e "CHANGE MASTER TO master_host='#{params[:ip_address]}', master_port=#{params[:port]}, master_user='#{params[:replication_user]}', master_password='#{params[:replication_password]}', master_log_file='#{params[:master_log_file]}', master_log_pos=#{params[:master_log_pos]};"]
%x[mysql -u root -e "START SLAVE;"]
end
Expand Down
1 change: 1 addition & 0 deletions percona/definitions/slave.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
if params[:action] == :create
ruby_block "create-replication-#{params[:name]}-user" do
block do
Chef::Log.info("Granting replication slave on *.* to #{params[:replication_user]}@#{params[:ip_address]}")
%x[mysql -u root -e "GRANT REPLICATION SLAVE ON *.* TO '#{params[:replication_user]}'@'#{params[:ip_address]}' IDENTIFIED BY '#{params[:replication_password]}';"]
end
not_if "mysql -u root -e \"SELECT user,host from mysql.user where user='#{params[:replication_user]}';\" | grep #{params[:replication_user]} | grep #{params[:ip_address]}"
Expand Down

0 comments on commit 79e277c

Please sign in to comment.