Skip to content

Instantly share code, notes, and snippets.

@dcampano
Created February 14, 2011 01:47
Show Gist options
  • Save dcampano/825380 to your computer and use it in GitHub Desktop.
Save dcampano/825380 to your computer and use it in GitHub Desktop.
bash "generate_random_server_id" do
user "root"
code <<-EOH
echo $RANDOM%900 | bc > /etc/mysql-server-id
EOH
not_if "test -f /etc/mysql-server-id"
end
ruby_block "reload_client_config" do
block do
server_id = IO.readlines('/etc/mysql-server-id','').to_s
node.run_state[:mysql_id] = server_id
Chef::Log.info("Server ID: #{server_id}")
end
action :create
end
template "/etc/my.cnf" do
source "my.cnf.erb"
mode 0644
variables(
:server_id => node.run_state[:mysql_id]
)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment