-
-
Save bknowles/b6d0b8c5d035b5bf95a7 to your computer and use it in GitHub Desktop.
Based on a modified version of the Opscode mysql cookbook for installing mysql-server, but taking into account the specific version of the server software we want to install. Starting around https://github.com/opscode-cookbooks/mysql/blob/master/recipes/server.rb#L94
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inspired by https://github.com/opscode-cookbooks/pxe_dust/blob/master/recipes/bootstrap_template.rb#L33 | |
# Thanks to Matt Ray <matt@opscode.com>, in Message-ID: <e85b33cc5b72421ab3ba9c0f325fe84f@CO1PR06MB078.namprd06.prod.outlook.com> | |
ruby_block "find-closest-matching-full-version" do | |
block do | |
aptitude = "aptitude show mysql-server=#{req_params['engVers']} | grep '^Version: ' | sed 's/^Version: //' | grep \"^#{req_params['engVers']}\"" | |
Chef::Log.debug aptitude | |
cmd = Mixlib::ShellOut.new(aptitude) | |
output = cmd.run_command | |
Chef::Log.debug output.stdout.chomp | |
node.set['engAvail'] = output.stdout.chomp | |
Chef::Log.debug("node['engAvail']='#{node['engAvail']}'") | |
end | |
not_if { File.exists? "/rdsdbdata/first_run" } | |
end | |
package "mysql-server" do | |
if(!node['engAvail'].nil?) | |
Chef::Log.debug("node['engAvail']='#{node['engAvail']}'") | |
Chef::Log.debug("req_params['engVers']='#{req_params['engVers']}'") | |
version node['engAvail'] | |
else | |
if(!req_params['engVers'].nil?) | |
Chef::Log.debug("req_params['engVers']='#{req_params['engVers']}'") | |
Chef::Log.debug("node['engAvail']='#{node['engAvail']}'") | |
version req_params['engVers'] | |
else | |
Chef::Log.debug("Both '#{req_params['engVers']}' and '#{node['engAvail']}' are nil") | |
end | |
end | |
action :nothing | |
subscribes :install, 'ruby_block[find-closest-matching-full-version]', :immediate | |
not_if { File.exists? "/rdsdbdata/first_run" } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment